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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to aneris from comment #0)
> The code compiles correctly if you replace all the long unsigned with just
> unsigned though, which I find very peculiar, the code also compiles with
> gnu++20 as the standard.

An iota_view with unsigned elements (i.e. 32-bit integers) can use 64-bit
integer for the difference_type of its iterators.

An iota_view with unsigned long elements (i.e. 64-bit integers) must use
something wider than 64 bits for the difference_type of its iterators. The
C++20 standard allows that to be an integer type or an integer-like class type.

In strict standard-conforming mode, we do not use the non-standard __int128
type for iota_view iterators, so we use an integer-like class type.

The Cpp17InputIterator requirements do not allow an integer-like class type to
be used, which means that in strict conformance mode, an iota_view with 64-bit
elements has iterators which do not meet the Cpp17InputIterator requirements.

You should not be assuming that C++20 ranges can be used in code that expects
class STL-style iterators. C++20 iterators and classic STL-style iterators are
not fully compatible with each other.

Reply via email to