[range.prim.size] (original) (raw)
25 Ranges library [ranges]
25.3 Range access [range.access]
25.3.10 ranges::size [range.prim.size]
Given a subexpression E with type T, let t be an lvalue that denotes the reified object for E.
Then:
- If T is an array of unknown bound ([dcl.array]),ranges::size(E) is ill-formed.
- Otherwise, if T is an array type,ranges::size(E) is expression-equivalent toauto(extent_v<T>).
- Otherwise, if disable_sized_range<remove_cv_t<T>> ([range.sized]) is false andauto(t.size()) is a valid expression of integer-like type ([iterator.concept.winc]),ranges::size(E) is expression-equivalent toauto(t.size()).
- Otherwise, if T is a class or enumeration type,disable_sized_range<remove_cv_t<T>> is false andauto(size(t)) is a valid expression of integer-like type where the meaning of size is established as-if by performing argument-dependent lookup only ([basic.lookup.argdep]), then ranges::size(E) is expression-equivalent to that expression.
- Otherwise, ranges::size(E) is ill-formed.
[Note 1:
Diagnosable ill-formed cases above result in substitution failure when ranges::size(E)appears in the immediate context of a template instantiation.
— _end note_]
[Note 2:
Whenever ranges::size(E) is a valid expression, its type is integer-like.
— _end note_]