[range.enumerate.iterator]

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

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.enumerate.iterator)

### 25.7.24 Enumerate view [[range.enumerate]](range.enumerate#iterator)

#### 25.7.24.3 Class template enumerate_view​::​*iterator* [range.enumerate.iterator]

[ð](#lib:enumerate_view::iterator)

namespace std::ranges {template<[view](range.view#concept:view "25.4.5 Views [range.view]") V>requires [*range-with-movable-references*](range.utility.helpers#concept:range-with-movable-references "25.5.2 Helper concepts [range.utility.helpers]")<V>template<bool Const>class enumerate_view<V>::*iterator* {using *Base* = *maybe-const*<Const, V>; // *exposition only*public:using iterator_category = input_iterator_tag; using iterator_concept = *see below*; using difference_type = range_difference_t<*Base*>; using value_type = tuple<difference_type, range_value_t<*Base*>>; private:using *reference-type* = // *exposition only* tuple<difference_type, range_reference_t<*Base*>>;
 iterator_t<*Base*> *current_* = iterator_t<*Base*>(); // *exposition only* difference_type *pos_* = 0; // *exposition only*constexpr explicit*iterator*(iterator_t<*Base*> current, difference_type pos); // *exposition only*public:*iterator*() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<iterator_t<*Base*>> = default; constexpr *iterator*(*iterator*<!Const> i)requires Const && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<iterator_t<V>, iterator_t<*Base*>>; constexpr const iterator_t<*Base*>& base() const & noexcept; constexpr iterator_t<*Base*> base() &&; constexpr difference_type index() const noexcept; constexpr auto operator*() const {return *reference-type*(*pos_*, **current_*); }constexpr *iterator*& operator++(); constexpr void operator++(int); constexpr *iterator* operator++(int) requires [forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator*& operator--() requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator* operator--(int) requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator*& operator+=(difference_type x)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator*& operator-=(difference_type x)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr auto operator[](difference_type n) constrequires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>{ return *reference-type*(*pos_* + n, *current_*[n]); }friend constexpr bool operator==(const *iterator*& x, const *iterator*& y) noexcept; friend constexpr strong_ordering operator<=>(const *iterator*& x, const *iterator*& y) noexcept; friend constexpr *iterator* operator+(const *iterator*& x, difference_type y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr *iterator* operator+(difference_type x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr *iterator* operator-(const *iterator*& x, difference_type y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr difference_type operator-(const *iterator*& x, const *iterator*& y) noexcept; friend constexpr auto iter_move(const *iterator*& i)noexcept(noexcept(ranges::iter_move(i.*current_*)) && is_nothrow_move_constructible_v<range_rvalue_reference_t<*Base*>>) {return tuple<difference_type,
 range_rvalue_reference_t<*Base*>>(i.*pos_*, ranges::iter_move(i.*current_*)); }};}

[1](#1)

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

The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]")*iterator*​::​iterator_concept is defined as follows:

- [(1.1)](#1.1)

  If *Base* models [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]"),
then iterator_concept denotes random_access_iterator_tag[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Otherwise, if *Base* models [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]"),
then iterator_concept denotes bidirectional_iterator_tag[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  Otherwise, if *Base* models [forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]"),
then iterator_concept denotes forward_iterator_tag[.](#1.3.sentence-1)

- [(1.4)](#1.4)

  Otherwise, iterator_concept denotes input_iterator_tag[.](#1.4.sentence-1)

[ð](#lib:enumerate_view::iterator,constructor)

`constexpr explicit iterator(iterator_t<Base> current, difference_type pos);
`

[2](#2)

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

*Effects*: Initializes *current_* with std​::​move(current) and*pos_* with pos[.](#2.sentence-1)

[ð](#lib:enumerate_view::iterator,constructor_)

`constexpr iterator(iterator<!Const> i)
  requires Const && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<iterator_t<V>, iterator_t<Base>>;
`

[3](#3)

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

*Effects*: Initializes *current_* with std​::​move(i.*current_*) and*pos_* with i.*pos_*[.](#3.sentence-1)

[ð](#lib:base,enumerate_view::iterator)

`constexpr const iterator_t<Base>& base() const & noexcept;
`

[4](#4)

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

*Effects*: Equivalent to: return *current_*;

[ð](#lib:base,enumerate_view::iterator_)

`constexpr iterator_t<Base> base() &&;
`

[5](#5)

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

*Effects*: Equivalent to: return std​::​move(*current_*);

[ð](#lib:index,enumerate_view::iterator)

`constexpr difference_type index() const noexcept;
`

[6](#6)

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

*Effects*: Equivalent to: return *pos_*;

[ð](#lib:operator++,enumerate_view::iterator)

`constexpr iterator& operator++();
`

[7](#7)

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

*Effects*: Equivalent to:++*current_*;++*pos_*;return *this;

[ð](#lib:operator++,enumerate_view::iterator_)

`constexpr void operator++(int);
`

[8](#8)

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

*Effects*: Equivalent to ++*this[.](#8.sentence-1)

[ð](#lib:operator++,enumerate_view::iterator__)

`constexpr iterator operator++(int) requires [forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[9](#9)

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

*Effects*: Equivalent to:auto temp = *this;++*this;return temp;

[ð](#lib:operator--,enumerate_view::iterator)

`constexpr iterator& operator--() requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[10](#10)

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

*Effects*: Equivalent to:--*current_*;--*pos_*;return *this;

[ð](#lib:operator--,enumerate_view::iterator_)

`constexpr iterator operator--(int) requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[11](#11)

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

*Effects*: Equivalent to:auto temp = *this;--*this;return temp;

[ð](#lib:operator+=,enumerate_view::iterator)

`constexpr iterator& operator+=(difference_type n)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[12](#12)

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

*Effects*: Equivalent to:*current_* += n;*pos_* += n;return *this;

[ð](#lib:operator-=,enumerate_view::iterator)

`constexpr iterator& operator-=(difference_type n)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[13](#13)

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

*Effects*: Equivalent to:*current_* -= n;*pos_* -= n;return *this;

[ð](#lib:operator==,enumerate_view::iterator)

`friend constexpr bool operator==(const iterator& x, const iterator& y) noexcept;
`

[14](#14)

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

*Effects*: Equivalent to: return x.*pos_* == y.*pos_*;

[ð](#lib:operator%3c=%3e,enumerate_view::iterator)

`friend constexpr strong_ordering operator<=>(const iterator& x, const iterator& y) noexcept;
`

[15](#15)

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

*Effects*: Equivalent to: return x.*pos_* <=> y.*pos_*;

[ð](#lib:operator+,enumerate_view::iterator)

`friend constexpr iterator operator+(const iterator& x, difference_type y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[16](#16)

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

*Effects*: Equivalent to:auto temp = x;
temp += y;return temp;

[ð](#lib:operator+,enumerate_view::iterator_)

`friend constexpr iterator operator+(difference_type x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[17](#17)

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

*Effects*: Equivalent to: return y + x;

[ð](#lib:operator-,enumerate_view::iterator)

`friend constexpr iterator operator-(const iterator& x, difference_type y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[18](#18)

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

*Effects*: Equivalent to:auto temp = x;
temp -= y;return temp;

[ð](#lib:operator-,enumerate_view::iterator_)

`friend constexpr difference_type operator-(const iterator& x, const iterator& y) noexcept;
`

[19](#19)

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

*Effects*: Equivalent to: return x.*pos_* - y.*pos_*;
