24 Ranges library [ranges]

24.3 Range access [range.access]

24.3.2 ranges​::​begin [range.access.begin]

The name ranges​::​begin denotes a customization point object ([customization.point.object]).
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 and enable_­borrowed_­range<remove_­cv_­t<T>> is false, ranges​::​begin(E) is ill-formed.
  • Otherwise, if T is an array type ([basic.compound]) and remove_­all_­extents_­t<T> is an incomplete type, ranges​::​begin(E) is ill-formed with no diagnostic required.
  • Otherwise, if T is an array type, ranges​::​begin(E) is expression-equivalent to t + 0.
  • Otherwise, if decay-copy(t.begin()) is a valid expression whose type models input_­or_­output_­iterator, ranges​::​begin(E) is expression-equivalent to decay-copy(t.begin()).
  • Otherwise, if T is a class or enumeration type and decay-copy(begin(t)) is a valid expression whose type models input_­or_­output_­iterator with overload resolution performed in a context in which unqualified lookup for begin finds only the declarations void begin(auto&) = delete; void begin(const auto&) = delete; then ranges​::​begin(E) is expression-equivalent to decay-copy(begin(t)) with overload resolution performed in the above context.
  • Otherwise, ranges​::​begin(E) is ill-formed.
[Note 1:
Diagnosable ill-formed cases above result in substitution failure when ranges​::​begin(E) appears in the immediate context of a template instantiation.
— end note]
[Note 2:
Whenever ranges​::​begin(E) is a valid expression, its type models input_­or_­output_­iterator.
— end note]