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.

3607.contiguous_iterator should not be allowed to have customiter_move anditer_swap behavior

Section: 24.3.4.14[iterator.concept.contiguous]Status:C++23Submitter: Tim SongOpened: 2021-09-28Last modified: 2023-11-22

Priority:Not Prioritized

View all otherissues in [iterator.concept.contiguous].

View all issues withC++23 status.

Discussion:

Theiter_move anditer_swap customization points were introducedprimarily for proxy iterators. Whatever their application to non-proxyiterators in general, they should not be allowed to have custombehavior for contiguous iterators — this new iterator category wasintroduced in large part to permit better optimizations, and allowingcustomiter_move/iter_swap prevents such optimizations for a widevariety of algorithms that are specified to call them.

[2021-10-14; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready → WP.]

Proposed resolution:

This wording is relative toN4892.

  1. Modify 24.3.4.14[iterator.concept.contiguous] as indicated:

    template<class I>  concept contiguous_iterator =    random_access_iterator<I> &&    derived_from<ITER_CONCEPT(I), contiguous_iterator_tag> &&    is_lvalue_reference_v<iter_reference_t<I>> &&    same_as<iter_value_t<I>, remove_cvref_t<iter_reference_t<I>>> &&    requires(const I& i) {      { to_address(i) } -> same_as<add_pointer_t<iter_reference_t<I>>>;    };

    -2- Leta andb be dereferenceable iterators andc be a non-dereferenceable iterator of typeI such thatb is reachable froma andc is reachable fromb, and letD beiter_difference_t<I>. The typeI modelscontiguous_iterator only if

    1. (2.1) —to_address(a) == addressof(*a),

    2. (2.2) —to_address(b) == to_address(a) + D(b - a),and

    3. (2.3) —to_address(c) == to_address(a) + D(c - a).,

    4. (2.?) —ranges::iter_move(a) has the same type, value category, and effects asstd::move(*a), and

    5. (2.?) — ifranges::iter_swap(a, b) is well-formed, it has effectsequivalent toranges::swap(*a, *b).


[8]ページ先頭

©2009-2026 Movatter.jp