I'm trying to create an iterator which only can dereference to real value types, not to references.
Is this possible using boost::iterator_facade
, or does it require me to have values that can be returned by adress\reference.
To be more specfic, my iterator returns a std::pair
of references, which means my iterators value_type
is not stored anywhere, but created on the fly on dereferencing (like std::map::iterator
).
Yes, thing you want is possible. Please, take a look at
boost/iterator_facade.hpp
(example is for Boost lib of version 1.49.0 but it is ok for its new distributions also):Template argument
Reference
is the key. You should just specifyReference
when deriving fromboost::iterator_facade
. For example, your code can look like as the following: