Add missing index_tuple.hpp header.
[luabind.git] / doc / return_stl_iterator.rst
blob320553108a2b5e4494ad5ac9840d7ea574712f83
1 return_stl_iterator
2 -------------------
4 Motivation
5 ~~~~~~~~~~
7 This policy converts an STL container to a generator function that can be used
8 in lua to iterate over the container. It works on any container that defines
9 ``begin()`` and ``end()`` member functions (they have to return iterators).
11 Defined in
12 ~~~~~~~~~~
14 .. parsed-literal::
16     #include <luabind/iterator_policy.hpp>
18 Synopsis
19 ~~~~~~~~
21 .. parsed-literal::
23     return_stl_iterator
25 Example
26 ~~~~~~~
28 .. parsed-literal::
30     struct X
31     {
32         std::vector<std::string> names;
33     };
35     ...
37     module(L)
38     [
39         class_<A>("A")
40             .def_readwrite("names", &X::names, **return_stl_iterator**)
41     ];
43     ...
45     > a = A()
46     > for name in a.names do
47     >  print(name)
48     > end