[range.access.rend]

# 25 Ranges library [[ranges]](./#ranges)

## 25.3 Range access [[range.access]](range.access#rend)

### 25.3.7 ranges​::​rend [range.access.rend]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L900)

The name ranges​::​rend denotes a customization point
object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L904)

Given a subexpression E with type T,
let t be an lvalue that denotes the reified object for E[.](#2.sentence-1)

Then:

- [(2.1)](#2.1)

  If E is an rvalue and enable_borrowed_range<remove_cv_t<T>> is false, ranges​::​rend(E) is ill-formed[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  Otherwise, if T is an array type ([[dcl.array]](dcl.array#term.array.type "9.3.4.5 Arrays")) and remove_all_extents_t<T> is an incomplete type, ranges​::​rend(E) is ill-formed with no diagnostic required[.](#2.2.sentence-1)

- [(2.3)](#2.3)

  Otherwise, if auto(t.rend()) is a valid expression whose type models [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<decltype(​ranges​::​rbegin(E))> then ranges​::​rend(E) is expression-equivalent to auto(t.rend())[.](#2.3.sentence-1)

- [(2.4)](#2.4)

  Otherwise, if T is a class or enumeration type and auto(rend(t)) is a valid expression whose type models [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<decltype(ranges​::​rbegin(E))> where the meaning of rend is established as-if by performing
 argument-dependent lookup only ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup")),
 then ranges​::​rend(E) is expression-equivalent to
 that expression[.](#2.4.sentence-1)

- [(2.5)](#2.5)

  Otherwise, if both ranges​::​begin(t) and ranges​::​end(t) are valid expressions of the same type which models [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]") ([[iterator.concept.bidir]](iterator.concept.bidir "24.3.4.12 Concept bidirectional_­iterator")),
 then ranges​::​rend(E) is expression-equivalent to make_reverse_iterator(ranges​::​begin(t))[.](#2.5.sentence-1)

- [(2.6)](#2.6)

  Otherwise, ranges​::​rend(E) is ill-formed[.](#2.6.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L947)

[*Note [1](#note-1)*:

Diagnosable ill-formed cases above
result in substitution failure when ranges​::​rend(E) appears in the immediate context of a template instantiation[.](#3.sentence-1)

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L954)

[*Note [2](#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](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<S, I>[.](#4.sentence-1)

â *end note*]
