-
Notifications
You must be signed in to change notification settings - Fork 8
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
Argument deduction constraints are specified incorrectly #330
Comments
This proposed resolution is ready for its close-up, @CaseyCarter. |
Unless I missed something, |
That's not wrong, but does generic code care? I consider this better than |
If generic code doesn't care about |
Generic code cares about the rvalue vs. lvalue distinction, but we haven't yet found an example usage where reasonable code cares about prvalue vs. xvalue. That said, I'm nervous that this is something that requires thought and investigation when we are honestly doing this to paper over the fact that Concepts has no good syntax for constraining the type and value category of an expression. I think it may be safer in the short run to replace EDIT: And if its ugliness encourages the development of a prettier syntax for type-and-value-category constraints, so much the better. EDIT 2: We cannot blindly replace |
I have little doubt that there are cases where generic code cares about rvalue vs. lvalue. I'm just somewhat doubtful that |
For Edit: and the result of calling |
The proposed changes to template <class I>
concept bool Readable() {
return Movable<I>() && DefaultConstructible<I>() &&
- requires(const I& i) {
- typename value_type_t<I>;
- typename reference_t<I>;
- typename rvalue_reference_t<I>;
- { *i } -> Same<reference_t<I>>;
- { ranges::iter_move(i) } -> Same<rvalue_reference_t<I>>;
- } &&
+ Same<reference_t<const I>, reference_t<I>>() &&
+ Same<rvalue_reference_t<const I>, rvalue_reference_t<I>>() &&
CommonReference<reference_t<I>, value_type_t<I>&>() &&
CommonReference<reference_t<I>, rvalue_reference_t<I>>() &&
CommonReference<rvalue_reference_t<I>, const value_type_t<I>&>();
} Edit: Broken type-and-value-category constraints or not, I think this is an improvement to Edit again: Oh, and remove the editorial note "(The |
I agree with @timsong-cpp about URNG, as well: If we don't care whether these functions return a prvalue or xvalue, we shouldn't care if they return an lvalue. The type is required to be an unsigned integral type, so object semantics are of no consequence here. (This is not the same as the pointer case we argued earlier, there are no types with stupid decay conversions to unsigned integer types.) |
See #155 for detailed discussion, but basically we've been operating under the faulty assumption that the following:
was trivially satisfied. It is not. Argument deduction constraints are handled as if the placeholder were made the argument type of an invented function
f
, likevoid f(Same<const T&>)
, and then a call were made likef(t)
. That causes the type oft
to decay.This should instead be written as:
That prevents argument decay from happening, which recovers the value category information.
We need to review and amend all the definitions and uses of concepts in the ranges ts.
(In our defense, this slipped through because early concepts implementations didn't do argument deduction constraints, so we invented a workaround, and the workaround was buggy because we didn't understand the model.)
Proposed Resolution:
Update section "Concept
Assignable
" ([concepts.lib.corelang.assignable]) and "ConceptDestructible
" ([concepts.lib.object.destructible]) as specified in P0547R1.Update sections "Concept
Boolean
" [concepts.lib.compare.boolean]), "ConceptEqualityComparable
" ([concepts.lib.compare.equalitycomparable]), "ConceptStrictTotallyOrdered
" ([concepts.lib.compare.stricttotallyordered]) as specified in #155.Update section "Concept
Readable
" ([iterators.readable]) as follows (also fixes #339):Change section "Concept
WeaklyIncrementable
" ([iterators.weaklyincrementable]) as follows:Change section "Concept
Incrementable
" ([iterators.incrementable]) as follows:Change section "Concept
SizedSentinel
" ([iterators.sizedsentinel]) as follows:Take the definition of concept
InputIterator
([iterators.input]) from P0541.Change section "Concept
BidirectionalIterator
" ([iterators.bidirectional]) as follows:Change section "Concept
RandomAccessIterator
" ([iterators.random.access]) as follows:Change section "Concept
UniformRandomNumberGenerator
" ([rand.req.urng]) as follows:The text was updated successfully, but these errors were encountered: