It's impossible for a proxy iterator (an iterator that yields temporaries) to be a RandomAccessIterator, or even a ForwardIterator:
- ForwardIterators must dereference to a true reference type.
- If you try to meet that requirement by making the iterator itself hold a temporary by value, and return a reference to that, you run afoul of the ForwardIterator "multi-pass requirement", which demands that any two iterators that compare equal yield references to the same object in memory.
I was unaware of the second condition when originally writing ndarray and afw::geom, and as a result we have a few proxy iterators that are incorrectly marked as RandomAccessIterators. The ones I've found so far are:
- ndarray's NestedIterator
Fixing these may require reimplementing them without using the Boost.Iterator library, which seems to use iterator traversal tags to both determine the iterator category and what methods to implement (these iterators should still have e.g. efficient += operators, even if we can't use an iterator tag to indicate that they exist).