[reverse.iter.nonmember]

# 24 Iterators library [[iterators]](./#iterators)

## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#reverse.iter.nonmember)

### 24.5.1 Reverse iterators [[reverse.iterators]](reverse.iterators#reverse.iter.nonmember)

#### 24.5.1.9 Non-member functions [reverse.iter.nonmember]

[ð](#lib:operator-,reverse_iterator)

`template<class Iterator1, class Iterator2>
  constexpr auto operator-(
    const reverse_iterator<Iterator1>& x,
    const reverse_iterator<Iterator2>& y) -> decltype(y.base() - x.base());
`

[1](#1)

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

*Returns*: y.base() - x.base()[.](#1.sentence-1)

[ð](#lib:operator+,reverse_iterator)

`template<class Iterator>
  constexpr reverse_iterator<Iterator> operator+(
    iter_difference_t<Iterator> n,
    const reverse_iterator<Iterator>& x);
`

[2](#2)

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

*Returns*: reverse_iterator<Iterator>(x.base() - n)[.](#2.sentence-1)

[ð](#lib:iter_move,reverse_iterator)

`friend constexpr iter_rvalue_reference_t<Iterator>
  iter_move(const reverse_iterator& i) noexcept(see below);
`

[3](#3)

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

*Effects*: Equivalent to:auto tmp = i.base();return ranges::iter_move(--tmp);

[4](#4)

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

*Remarks*: The exception specification is equivalent to:is_nothrow_copy_constructible_v<Iterator> &&noexcept(ranges::iter_move(--declval<Iterator&>()))

[ð](#lib:iter_swap,reverse_iterator)

`template<[indirectly_swappable](alg.req.ind.swap#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")<Iterator> Iterator2>
  friend constexpr void
    iter_swap(const reverse_iterator& x,
              const reverse_iterator<Iterator2>& y) noexcept(see below);
`

[5](#5)

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

*Effects*: Equivalent to:auto xtmp = x.base();auto ytmp = y.base();
ranges::iter_swap(--xtmp, --ytmp);

[6](#6)

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

*Remarks*: The exception specification is equivalent to:is_nothrow_copy_constructible_v<Iterator> && is_nothrow_copy_constructible_v<Iterator2> &&noexcept(ranges::iter_swap(--declval<Iterator&>(), --declval<Iterator2&>()))

[ð](#lib:reverse_iterator,make_reverse_iterator_non-member_function)

`template<class Iterator>
  constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i);
`

[7](#7)

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

*Returns*: reverse_iterator<Iterator>(i)[.](#7.sentence-1)
