10 Ranges library [ranges]

10.4 Range access [range.access]

In addition to being available via inclusion of the <experimental/ranges/range> header, the customization point objects in [range.access] are available when <experimental/ranges/iterator> is included.

10.4.1 begin [range.access.begin]

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

  • ranges::begin(static_cast<const T&>(E)) if E is an rvalue of type T. This usage is deprecated. [ Note: This deprecated usage exists so that ranges::begin(E) behaves similarly to std::begin(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

  • Otherwise, (E) + 0 if E has array type ( ISO/IEC 14882:2014 §[basic.compound]).

  • Otherwise, DECAY_COPY((E).begin()) if it is a valid expression and its type I meets the syntactic requirements of Iterator<I>. If Iterator is not satisfied, the program is ill-formed with no diagnostic required.

  • Otherwise, DECAY_COPY(begin(E)) if it is a valid expression and its type I meets the syntactic requirements of Iterator<I> with overload resolution performed in a context that includes the declaration void begin(auto&) = delete; and does not include a declaration of ranges::begin. If Iterator is not satisfied, the program is ill-formed with no diagnostic required.

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

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

10.4.2 end [range.access.end]

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

  • ranges::end(static_cast<const T&>(E)) if E is an rvalue of type T. This usage is deprecated. [ Note: This deprecated usage exists so that ranges::end(E) behaves similarly to std::end(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

  • Otherwise, (E) + extent<T>::value if E has array type ( ISO/IEC 14882:2014 §[basic.compound]) T.

  • Otherwise, DECAY_COPY((E).end()) if it is a valid expression and its type S meets the syntactic requirements of Sentinel<S, decltype(ranges::begin(E))>. If Sentinel is not satisfied, the program is ill-formed with no diagnostic required.

  • Otherwise, DECAY_COPY(end(E)) if it is a valid expression and its type S meets the syntactic requirements of Sentinel<S, decltype(ranges::begin(E))> with overload resolution performed in a context that includes the declaration void end(auto&) = delete; and does not include a declaration of ranges::end. If Sentinel is not satisfied, the program is ill-formed with no diagnostic required.

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

Note: Whenever ranges::end(E) is a valid expression, the types of ranges::end(E) and ranges::begin(E) satisfy Sentinel.  — end note ]

10.4.3 cbegin [range.access.cbegin]

The name cbegin denotes a customization point object ([customization.point.object]). The expression ranges::cbegin(E) for some subexpression E of type T is expression-equivalent to ranges::begin(static_cast<const T&>(E)).

Use of ranges::cbegin(E) with rvalue E is deprecated. [ Note: This deprecated usage exists so that ranges::cbegin(E) behaves similarly to std::cbegin(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

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

10.4.4 cend [range.access.cend]

The name cend denotes a customization point object ([customization.point.object]). The expression ranges::cend(E) for some subexpression E of type T is expression-equivalent to ranges::end(static_cast<const T&>(E)).

Use of ranges::cend(E) with rvalue E is deprecated. [ Note: This deprecated usage exists so that ranges::cend(E) behaves similarly to std::cend(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

Note: Whenever ranges::cend(E) is a valid expression, the types of ranges::cend(E) and ranges::cbegin(E) satisfy Sentinel.  — end note ]

10.4.5 rbegin [range.access.rbegin]

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

  • ranges::rbegin(static_cast<const T&>(E)) if E is an rvalue of type T. This usage is deprecated. [ Note: This deprecated usage exists so that ranges::rbegin(E) behaves similarly to std::rbegin(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

  • Otherwise, DECAY_COPY((E).rbegin()) if it is a valid expression and its type I meets the syntactic requirements of Iterator<I>. If Iterator is not satisfied, the program is ill-formed with no diagnostic required.

  • Otherwise, make_reverse_iterator(ranges::end(E)) if both ranges::begin(E) and ranges::end(E) are valid expressions of the same type I which meets the syntactic requirements of BidirectionalIterator<I> ([iterators.bidirectional]).

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

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

10.4.6 rend [range.access.rend]

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

  • ranges::rend(static_cast<const T&>(E)) if E is an rvalue of type T. This usage is deprecated. [ Note: This deprecated usage exists so that ranges::rend(E) behaves similarly to std::rend(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

  • Otherwise, DECAY_COPY((E).rend()) if it is a valid expression and its type S meets the syntactic requirements of Sentinel<S, decltype(ranges::rbegin(E))>. If Sentinel is not satisfied, the program is ill-formed with no diagnostic required.

  • Otherwise, make_reverse_iterator(ranges::begin(E)) if both ranges::begin(E) and ranges::end(E) are valid expressions of the same type I which meets the syntactic requirements of BidirectionalIterator<I> ([iterators.bidirectional]).

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

Note: Whenever ranges::rend(E) is a valid expression, the types of ranges::rend(E) and ranges::rbegin(E) satisfy Sentinel.  — end note ]

10.4.7 crbegin [range.access.crbegin]

The name crbegin denotes a customization point object ([customization.point.object]). The expression ranges::crbegin(E) for some subexpression E of type T is expression-equivalent to ranges::rbegin(static_cast<const T&>(E)).

Use of ranges::crbegin(E) with rvalue E is deprecated. [ Note: This deprecated usage exists so that ranges::crbegin(E) behaves similarly to std::crbegin(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

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

10.4.8 crend [range.access.crend]

The name crend denotes a customization point object ([customization.point.object]). The expression ranges::crend(E) for some subexpression E of type T is expression-equivalent to ranges::rend(static_cast<const T&>(E)).

Use of ranges::crend(E) with rvalue E is deprecated. [ Note: This deprecated usage exists so that ranges::crend(E) behaves similarly to std::crend(E) as defined in ISO/IEC 14882 when E is an rvalue.  — end note ]

Note: Whenever ranges::crend(E) is a valid expression, the types of ranges::crend(E) and ranges::crbegin(E) satisfy Sentinel.  — end note ]