File: return_stl_iterator.rst

package info (click to toggle)
luabind 0.9.1%2Bdfsg-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,460 kB
  • sloc: cpp: 13,761; makefile: 120; sh: 24; ansic: 11
file content (49 lines) | stat: -rwxr-xr-x 769 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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