On Mon, Aug 22, 2011 at 4:53 PM, Sebastian Redl
<sebastian.redl@getdesigned.at> wrote:
On 22.08.2011 13:09, Ovanes Markarian wrote:
[..]
std::advance will switch implementations based on the standard
iterator tags, i.e. std::input_iterator_tag,
std::forward_iterator_tag, std::bidirectional_iterator_tag and
std::random_access_iterator_tag. (Actually, forward isn't treated
any different than input in std::advance.) These categories conflate
traversal and access. The problem is that to be a forward iterator,
the associated type 'reference' must be a true reference. So
whenever that isn't the case, the iterator is an input_iterator, no
matter how you can navigate it.
Ok, thanks. I was aware of iterator categories, but did not know that advance really is going to make a decision dependent on reference type and not the iterator category. If that is true what you have written, than vector<bool> must be either a forward_iterator sequence or advance is also specialized for vector<boost>::iterator and ...const_iterator respectively.
Boost.Iterator separates the concepts, and so it has
boost::one_pass_traversal_tag, boost::forward_traversal_tag,
boost::bidirectional_traversal_tag, and
boost::random_access_traversal_tag. However, you would need an
advance algorithm that is aware of these tags. No std::advance I
know is, so basically, you can't use it. (I'm not sure if you're
allowed to specialize std::advance.)
AFAIK users are allowed to specialize the std templates but are disallowed to overload them.
I was hoping to solve it more elegantly, but thanks for your help anyway.