Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++23 status.

3420.cpp17-iterator should check that the type looks like an iterator first

Section: 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).

C++20 changediterator_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 […].

To reduce the risk of constraint recursion, we should changecpp17-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.

  1. 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>;  […]

[8]ページ先頭

©2009-2026 Movatter.jp