Skip to content

Commit eb3e237

Browse files
committed
Added a compile-only test for functions returning non-const references
[SVN r15420]
1 parent b1796c0 commit eb3e237

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/iterator.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ int back(list_int& x)
3838

3939
typedef 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+
4147
list_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

0 commit comments

Comments
 (0)