https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113074

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It looks like libc++ did it for this reason:

[libc++] Fix a hard error in `contiguous_iterator<NoOperatorArrowIter>`.

Evaluating `contiguous_iterator` on an iterator that satisfies all the
constraints except the `to_address` constraint and doesn't have
`operator->` defined results in a hard error. This is because
instantiating `to_address` ends up instantiating templates
dependent on the given type which might lead to a hard error even
in a SFINAE context.

Differential Revision: https://reviews.llvm.org/D130835


As I said in comment 7, LWG considered this case and it was pointed out that
the problem described can only occur if a type defines iterator_concept =
contiguous_iterator; but then fails to actually provide the operations needed
for a contiguous iterator (i.e. either a pointer_traits specialization with
to_address or a sane operator->()).

A SFINAE-friendly std::to_address as implemented in libc++ means that such an
iterator will fail to satisfy std::contiguous_iterator and will silently
degrade to satosfying std::random_access_iterator only. It's not at all clear
to me that silently degrading such an iterator (which very explicitly claims to
be a contiguous iterator by defining iterator_concept to say so) would be an
improvement. I'd rather get an error telling me the thing I thought was a
contiguous iterator was not actually.

Reply via email to