10 Ranges library [ranges]

10.5 Range primitives [range.primitives]

10.5.1 size [range.primitives.size]

The name size denotes a customization point object ([customization.point.object]). The expression ranges::size(E) for some subexpression E with type T is expression-equivalent to:

  • DECAY_COPY(extent<T>::value) if T is an array type ( ISO/IEC 14882:2014 §[basic.compound]).

  • Otherwise, DECAY_COPY(static_cast<const T&>(E).size()) if it is a valid expression and its type I satisfies Integral<I> and disable_sized_range<T> ([ranges.sized]) is false.

  • Otherwise, DECAY_COPY(size(static_cast<const T&>(E))) if it is a valid expression and its type I satisfies Integral<I> with overload resolution performed in a context that includes the declaration void size(const auto&) = delete; and does not include a declaration of ranges::size, and disable_sized_range<T> is false.

  • Otherwise, DECAY_COPY(ranges::cend(E) - ranges::cbegin(E)), except that E is only evaluated once, if it is a valid expression and the types I and S of ranges::cbegin(E) and ranges::cend(E) meet the syntactic requirements of SizedSentinel<S, I> ([iterators.sizedsentinel]) and ForwardIterator<I>. If SizedSentinel and ForwardIterator are not satisfied, the program is ill-formed with no diagnostic required.

  • Otherwise, ranges::size(E) is ill-formed.

Note: Whenever ranges::size(E) is a valid expression, its type satisfies Integral.  — end note ]