File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ int back(list_int& x)
3838
3939typedef std::pair<list_int::iterator,list_int::iterator> list_range;
4040
41+ struct list_range2 : list_range
42+ {
43+ list_int::iterator& begin () { return this ->first ; }
44+ list_int::iterator& end () { return this ->second ; }
45+ };
46+
4147list_range range (list_int& x)
4248{
4349 return list_range (x.begin (), x.end ());
@@ -88,6 +94,12 @@ BOOST_PYTHON_MODULE_INIT(iterator_ext)
8894 , range (&list_range::first, &list_range::second))
8995 ;
9096
97+ class_<list_range2>(" list_range2" )
98+
99+ // We can specify member functions returning a non-const reference
100+ .def (" __iter__" , range (&list_range2::begin, &list_range2::end))
101+ ;
102+
91103 class_<two_lists>(" two_lists" )
92104
93105 // We can spcify member functions
You can’t perform that action at this time.
0 commit comments