filter_iterator usage
Hi,
I have a class with some custom iterators, I would like to add another custom
iterator that is a 'filtered' version of the custom iterator. Something like this:
class A
{
public:
typedef boost::filter_iterator
Nico Galoppo
Hi,
I have a class with some custom iterators, I would like to add another custom iterator that is a 'filtered' version of the custom iterator. Something like this:
class A { public: typedef boost::filter_iterator
filtered_iterator; filtered_iterator begin() { predicate_type predicate = boost::bind(...); return boost::make_filter_iterator(predicate, custom_begin(), custom_end()); } }
Unfortunately, the following code doesn't compile:
A a; A::filtered_iterator it = a.begin();
Reason: cannot convert from 'boost::filter_iterator
' to 'const boost::filter_iterator ' I can give more compiler output if needed.
Most likely the important output is in the following lines in a pair of "with" clauses. In the two clauses, you should expect to see that either Predicate or Iterator don't match up. I suggest you not use make_filter_iterator when you already know the type of iterator you're creating anyway. Instead, just use constructor syntax: return filtered_iterator(predicate, custom_begin(), custom_end()); -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Nico Galoppo