I determine the type of iterator that does not explicitly store its current value. Instead, it wraps around another iterator and returns the std::pairbase values of the iterator and another value. The relevant part of the class definition:
class MyIterator : public std::iterator<input_iterator, std::pair<Foo *, Bar *> > {
FooPtrIterator d_iter;
Bar d_bar;
public:
MyIterator(FooPtrIterator iter, Bar const &bar)
:
d_iter(iter),
d_bar(bar)
{ }
value_type operator*() const {
return std::make_pair(*d_iter, &d_bar);
}
??? operator->() const {
return ???;
}
};
Now I am having problems with overloading operator->because I have to return a pointer or something else that itself supports it operator->.
I could just save the current std::pairas a member of the class:
value_type d_current;
However, this causes me problems with the constructor, because I cannot know at this moment whether FooPtrIterator iterit is a valid iterator, so I cannot dereference it to provide a d_currentvalue.
operator-> return a boost::shared_ptr<value_type>, , .
, "" . , ?