|
Boost : |
Subject: Re: [boost] [iterator] Silent-but-deadly bug in iterator_facade category
From: Gabriel Redner (gredner_at_[hidden])
Date: 2013-05-06 17:42:11
Hi Paul,
Thanks for your reply.
> For it to be a
> `std::random_access_iterator_tag` it must a reference. That is,
> `iterator_traits<X>::reference` must be an actual reference.
Can you point me at a reference (pun not intended) for this
requirement? The sites I've looked at don't mention this [1-3]. Is
it a requirement for, say, bidirectional iterators too? Your message
makes it sound like this is specific to random access iterators.
If the iterator's reference must be a real reference type, then why
does iterator_facade not check this at compile time?
And in any case, isn't this a flaw? my_iterator can be advanced etc.
in constant time - why should the STL be forced to use a
possibly-suboptimal overload of some algorithm on account of the
reference type?
Confused,
-Gabe
[1] http://www.cplusplus.com/reference/iterator/RandomAccessIterator/
[2] http://en.cppreference.com/w/cpp/concept/RandomAccessIterator
[3] http://www.sgi.com/tech/stl/RandomAccessIterator.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk