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

Reorder requirements in concept Iterator #331

Closed
ericniebler opened this issue Feb 17, 2017 · 0 comments
Closed

Reorder requirements in concept Iterator #331

ericniebler opened this issue Feb 17, 2017 · 0 comments

Comments

@ericniebler
Copy link
Owner

ericniebler commented Feb 17, 2017

When passing a std::vector<MoveOnly> to sort, overload resolution causes the evaluation of Iterator<std::vector<MoveOnly>>, which tests the vector type for assignability. Vectors of move-only types are not assignable, but their assignment operators are not properly constrained. That leads to a hard error rather than a concept check failure.

The problem can be mostly avoided by testing for dereferencability first in concept Iterator, as shows in the Proposed Resolution below.

Proposed Resolution

Change concept Iterator ([iterators.iterator]) as follows:

 template <class I>
 concept bool Iterator() {
-   return WeaklyIncrementable<I>() &&
-     requires(I i) {
-       { *i } -> auto&&; // Requires: i is dereferenceable
-     };
+   return requires(I i) {
+     { *i } -> auto&&; // Requires: i is dereferenceable
+   } && WeaklyIncrementable<I>();
 }
ericniebler added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 17, 2017
…icniebler/stl2#155); remove argument deduction constraint work-arounds; fix up deduction constraints (refs ericniebler/stl2#331)
ericniebler added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 17, 2017
…icniebler/stl2#155); remove argument deduction constraint work-arounds; fix up deduction constraints (refs ericniebler/stl2#331)
ericniebler added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 17, 2017
…icniebler/stl2#155); remove argument deduction constraint work-arounds; fix up deduction constraints (refs ericniebler/stl2#331)
ericniebler added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 17, 2017
…icniebler/stl2#155); remove argument deduction constraint work-arounds; fix up deduction constraints (refs ericniebler/stl2#331)
CaseyCarter pushed a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 18, 2017
…ance (#76)

* Fix up Boolean, EqualityComparable, and StrictTotallyOrdered (refs ericniebler/stl2#155); remove argument deduction constraint work-arounds; fix up deduction constraints (refs ericniebler/stl2#331)

* fix Assignable per discussion with @CaseyCarter
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

2 participants