Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ericniebler opened this issue Sep 10, 2019 · 0 comments
Open

Comments

@ericniebler
Copy link
Owner

ericniebler commented Sep 10, 2019

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>;
   };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant