ericniebler/stl2

Exposition-only cpp17-input-iterator concept is needlessly complex

ericniebler opened this issue · 0 comments

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.

Proposed Resolution

Change [iterator.traits]/p2 as follows:

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>;
   };