Title
Exposition-only cpp17-input-iterator concept is needlessly complex
Status
new
Section
[iterator.traits]
Submitter
Eric Niebler

Created on 2019-09-10.00:00:00 last changed 62 months ago

Messages

Date: 2019-10-14.17:22:27

Proposed resolution:

This wording is relative to N4830.

  1. Modify [iterator.traits] as indicated:

    -2- The definitions in this subclause make use of the following exposition-only concepts:

    template<class I>
    concept cpp17-iterator =
      copyable<I> && requires(I i) {
        {   *i } -> can-reference;
        {  ++i } -> same_as<I&>;
        { *i++ } -> can-reference;
      };
    
    template<class I>
    concept cpp17-input-iterator =
      cpp17-iterator<I> && equality_comparable<I> && requires(I i) {
        typename incrementable_traits<I>::difference_type;
        typename readable_traits<I>::value_type;
        typename common_reference_t<iter_reference_t<I>&&,
                                    typename readable_traits<I>::value_type&>;
        typename common_reference_t<decltype(*i++)&&,
                                    typename readable_traits<I>::value_type&>;
        { *i } -> convertible_to<const typename readable_traits<I>::value_type&>;
        { *i++ } -> convertible_to<const typename readable_traits<I>::value_type&>;
        requires signed_integral<typename incrementable_traits<I>::difference_type>;
      };
    
    […]
    
Date: 2019-10-14.00:00:00

[ 2019-10-14 Issue Prioritization ]

Priority to 3 after reflector discussion.

Date: 2019-09-17.17:03:20

The new C++20 iterator concepts use common_reference to constrain the value, reference, and rvalue_reference associated types in order to support proxy references (see [iterator.concept.readable]).

However, the C++17 iterators did not support proxy references, so the use of common_reference in [iterator.traits]/p2 is needlessly complex. The common_reference constraints can be replaced with simple convertibility requirements to a const lvalue reference to the value type.

This fix has been implemented in range-v3.

History
Date User Action Args
2019-10-14 17:22:27adminsetmessages: + msg10701
2019-09-17 17:00:52adminsetmessages: + msg10645
2019-09-10 00:00:00admincreate