[range.reverse.overview]

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

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.reverse.overview)

### 25.7.21 Reverse view [[range.reverse]](range.reverse#overview)

#### 25.7.21.1 Overview [range.reverse.overview]

[1](#1)

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

reverse_view takes a bidirectional view and produces
another view that iterates the same elements in reverse order[.](#1.sentence-1)

[2](#2)

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

The name views​::​reverse denotes a
range adaptor object ([[range.adaptor.object]](range.adaptor.object "25.7.2 Range adaptor objects"))[.](#2.sentence-1)

Given a subexpression E, the expressionviews​::​reverse(E) is expression-equivalent to:

- [(2.1)](#2.1)

  If the type of E is
 a (possibly cv-qualified) specialization of reverse_view,
 then E.base()[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  Otherwise, if the type of E is cv subrange<reverse_iterator<I>, reverse_iterator<I>, K> for some iterator type I and
 value K of type subrange_kind,
  * [(2.2.1)](#2.2.1)

if K is subrange_kind​::​sized, thensubrange<I, I, K>(E.end().base(), E.begin().base(), E.size());

  * [(2.2.2)](#2.2.2)

otherwise, subrange<I, I, K>(E.end().base(), E.begin().base())[.](#2.2.sentence-1)

   However, in either case E is evaluated only once[.](#2.2.sentence-2)

- [(2.3)](#2.3)

  Otherwise, reverse_view{E}[.](#2.3.sentence-1)

[3](#3)

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

[*Example [1](#example-1)*: vector<int> is {0,1,2,3,4};for (int i : is | views::reverse) cout << i << ' '; // prints 4 3 2 1 0 â *end example*]
