|
Boost Users : |
From: Jörg Becker (news_at_[hidden])
Date: 2008-04-09 12:15:17
Hello,
I want to expose a begin and end method which takes one argument and returns
an iterator as a python iterator. Here is an example:
struct range_test {
typedef std::list< int > my_type;
typedef my_type::iterator iterator;
my_type m_vals;
my_type::iterator begin ( int i ) { return m_vals.begin(); }
my_type::iterator end ( int i ) { return m_vals.end();}
};
class_< range_test >( "range_test" )
.def( "get_iter", range( &range_test::begin, &range_test::end ) )
;
If I import this, python exists immediately without any error message. Trying
it with wrappers, I get a (gcc) compile error saying my wrapper function is
not a class, struct, or union type:
range_test::iterator begin( range_test & t, int i ) { return t.begin( i ); }
range_test::iterator end( range_test & t, int i ) { return t.end( i ); }
class_< range_test >( "range_test" )
.def( "get_iter", range( &range_test::begin, &range_test::end ) )
.def( "iter_wrapper", range( begin, end ) )
;
So I'm wondering how to expose such iterators, e.g. a method taking a
predicate and returning a filter_iterator.
Thanks for any help
Jörg
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net