[range.access.rend] (original) (raw)
25 Ranges library [ranges]
25.3.7 ranges::rend [range.access.rend]
Given a subexpression E with type T, let t be an lvalue that denotes the reified object for E.
Then:
- If E is an rvalue andenable_borrowed_range<remove_cv_t<T>> is false,ranges::rend(E) is ill-formed.
- Otherwise, if T is an array type ([dcl.array]) andremove_all_extents_t<T> is an incomplete type,ranges::rend(E) is ill-formed with no diagnostic required.
- Otherwise, if auto(t.rend()) is a valid expression whose type modelssentinel_for<decltype(ranges::rbegin(E))> then ranges::rend(E) is expression-equivalent toauto(t.rend()).
- Otherwise, if T is a class or enumeration type andauto(rend(t)) is a valid expression whose type modelssentinel_for<decltype(ranges::rbegin(E))> where the meaning of rend is established as-if by performing argument-dependent lookup only ([basic.lookup.argdep]), then ranges::rend(E) is expression-equivalent to that expression.
- Otherwise, if both ranges::begin(t) and ranges::end(t) are valid expressions of the same type which modelsbidirectional_iterator ([iterator.concept.bidir]), then ranges::rend(E) is expression-equivalent tomake_reverse_iterator(ranges::begin(t)).
- Otherwise, ranges::rend(E) is ill-formed.
[Note 1:
Diagnosable ill-formed cases above result in substitution failure when ranges::rend(E)appears in the immediate context of a template instantiation.
— _end note_]
[Note 2:
Whenever ranges::rend(E) is a valid expression, the types S and I of the expressionsranges::rend(E) and ranges::rbegin(E)model sentinel_for<S, I>.
— _end note_]