This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++23 status.
cpp17-iterator should check that the type looks like an iterator firstSection: 24.3.2.3[iterator.traits]Status:C++23Submitter: Tim SongOpened: 2020-02-29Last modified: 2023-11-22
Priority:0
View all otherissues in [iterator.traits].
View all issues withC++23 status.
Discussion:
It is common in pre-C++20 code to rely on SFINAE-friendlyiterator_traits to rule out non-iterators in template constraints (std::filesystem::path is one example in the standard library).
iterator_traits to automatically detect its members insome cases, and this detection can cause constraint recursion. LWG3244(i) tries to fix this forpath by short-circuiting the check when the source type ispath itself, but this isn't sufficient:struct Foo { Foo(const std::filesystem::path&);};static_assert(std::copyable<Foo>);Here the copyability determination will ask whether apath can beconstructed from aFoo, which asks whetherFoo is an iterator, whichchecks whetherFoo iscopyable […].
cpp17-iterator so that it does not ask about copyability until the type is known to resemble an iterator.[2020-04-04 Issue Prioritization]
Status set to Tentatively Ready after six positive votes on the reflector.
[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP.]
Proposed resolution:
This wording is relative toN4861.
Modify 24.3.2.3[iterator.traits] as indicated:
-2- The definitions in this subclause make use of the following exposition-only concepts:
template<class I>conceptcpp17-iterator =copyable<I> &&requires(I i) { { *i } ->can-reference; { ++i } -> same_as<I&>; { *i++ } ->can-reference; }&& copyable<I>; […]