Iterator behaving like an indirect_iterator and a filter_iterator
Hi everyone,
I wanted to know if it was possible to have an iterator behaving like
both an indirect_iterator and a filter_iterator. I've tried to without
success.
Here is a minimal code that compiles but crashes.
=====================================
class CTest {
public:
CTest(int Value,int Id) : value(Value),id(Id) {};
int id;
int value;
};
std::vector
AMDG Teto wrote:
I wanted to know if it was possible to have an iterator behaving like both an indirect_iterator and a filter_iterator. I've tried to without success.
Here is a minimal code that compiles but crashes. ===================================== class CTest {
public: CTest(int Value,int Id) : value(Value),id(Id) {}; int id; int value;
};
std::vector
vec; vec.push_back(new CTest(4,7)); vec.push_back(new CTest(4,1)); //I want an iterator that I could use like iter->id / iter->value and not (*iter)->id / (*iter)->value
struct SPredicate { bool operator()( C& x) { return (-1 < x.id); } };
typedef boost::filter_iterator
FilterIterator;
Try boost::filter_iterator
FilteredIterator end(*vec.end());
for(FilteredIterator iter(*vec.begin());start != end; iter++){ std::cout << "id" << iter->id << "\tValue" << iter->m << std::endl; } =====================================
I'm new to boost and is very impressed by its possibilites. Hope I can understand the code better later.
In Christ, Steven Watanabe
Teto wrote:
I wanted to know if it was possible to have an iterator behaving like both an indirect_iterator and a filter_iterator. I've tried to without success.
Are you sure you want to do this with individual iterators? How about ranges (equivalent to iterator pairs)? You should look at the RangeEx library. http://article.gmane.org/gmane.comp.lib.boost.user/44819
participants (3)
-
Nat Goodspeed
-
Steven Watanabe
-
Teto