Sophie

Sophie

distrib > Fedora > 13 > x86_64 > media > updates > by-pkgid > 2cb8864ce5795b07e9b4918eb1189588 > files > 100

luabind-devel-0.9.1-1.fc13.x86_64.rpm

return_stl_iterator
-------------------

Motivation
~~~~~~~~~~

This policy converts an STL container to a generator function that can be used
in lua to iterate over the container. It works on any container that defines
``begin()`` and ``end()`` member functions (they have to return iterators).

Defined in
~~~~~~~~~~

.. parsed-literal::

    #include <luabind/iterator_policy.hpp>

Synopsis
~~~~~~~~

.. parsed-literal::

    return_stl_iterator

Example
~~~~~~~

.. parsed-literal::

    struct X
    {
        std::vector<std::string> names;
    };

    ...

    module(L)
    [
        class_<A>("A")
            .def_readwrite("names", &X::names, **return_stl_iterator**)
    ];

    ...

    > a = A()
    > for name in a.names do
    >  print(name)
    > end