------- Comment #31 from redi at gcc dot gnu dot org 2010-05-27 10:21 ------- (In reply to comment #23) > I can't see any 100% reliable way to prevent this problem, because the > catch-all specialisation of iterator_traits can be instantiated with > non-iterator types.
I was under the impression that the default specialisation of iterator_traits was meant to be catch-all, but Alisdair Meredith described his implementation and I realised that the definition in [iterator.traits]/2 applies to type "Iterator" and [iterator.traits]/1 says "if Iterator is the type of an iterator" So now I believe that we can (and should) restrict that specialisation to types that really are iterators. If iterator_traits<NotAnIterator>::difference_type doesn't exist then SFINAE will apply and std::next/std::prev will not cause invalid instantiations. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40497