[const.iterators.ops]

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

## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#const.iterators.ops)

### 24.5.3 Constant iterators and sentinels [[const.iterators]](const.iterators#ops)

#### 24.5.3.5 Operations [const.iterators.ops]

[ð](#lib:basic_const_iterator,constructor)

`constexpr basic_const_iterator(Iterator current);
`

[1](#1)

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

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

[ð](#lib:basic_const_iterator,constructor_)

`template<[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<Iterator> U>
  constexpr basic_const_iterator(basic_const_iterator<U> current);
`

[2](#2)

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

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

[ð](#lib:basic_const_iterator,constructor__)

`template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> T>
  requires [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<T, Iterator>
  constexpr basic_const_iterator(T&& current);
`

[3](#3)

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

*Effects*: Initializes *current_* with std​::​forward<T>(current)[.](#3.sentence-1)

[ð](#lib:base,basic_const_iterator)

`constexpr const Iterator& base() const & noexcept;
`

[4](#4)

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

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

[ð](#lib:base,basic_const_iterator_)

`constexpr Iterator base() &&;
`

[5](#5)

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

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

[ð](#lib:operator*,basic_const_iterator)

`constexpr reference operator*() const;
`

[6](#6)

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

*Effects*: Equivalent to: return static_cast<*reference*>(**current_*);

[ð](#lib:operator-%3e,basic_const_iterator)

`constexpr const auto* operator->() const
  requires is_lvalue_reference_v<iter_reference_t<Iterator>> &&
           [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<remove_cvref_t<iter_reference_t<Iterator>>, value_type>;
`

[7](#7)

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

*Returns*: If Iterator models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_­iterator [iterator.concept.contiguous]"),to_address(*current_*);
otherwise, addressof(**current_*)[.](#7.sentence-1)

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

`constexpr basic_const_iterator& operator++();
`

[8](#8)

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

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

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

`constexpr void operator++(int);
`

[9](#9)

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

*Effects*: Equivalent to: ++*current_*;

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

`constexpr basic_const_iterator operator++(int) requires [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]")<Iterator>;
`

[10](#10)

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

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

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

`constexpr basic_const_iterator& operator--() requires [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]")<Iterator>;
`

[11](#11)

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

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

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

`constexpr basic_const_iterator operator--(int) requires [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]")<Iterator>;
`

[12](#12)

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

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

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

`constexpr basic_const_iterator& operator+=(difference_type n)
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
constexpr basic_const_iterator& operator-=(difference_type n)
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
`

[13](#13)

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

Let *op* be the operator[.](#13.sentence-1)

[14](#14)

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

*Effects*: Equivalent to:*current_* *op* n;return *this;

[ð](#lib:operator%5b%5d,basic_const_iterator)

`constexpr reference operator[](difference_type n) const requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>
`

[15](#15)

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

*Effects*: Equivalent to: return static_cast<*reference*>(*current_*[n]);

[ð](#lib:operator==,basic_const_iterator)

`template<[sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<Iterator> S>
  constexpr bool operator==(const S& s) const;
`

[16](#16)

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

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

[ð](#itemdecl:16)

`template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI>
  requires [constant-iterator](const.iterators.alias#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]")<CI> && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<Iterator const&, CI>
constexpr operator CI() const &;
`

[17](#17)

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

*Returns*: *current_*[.](#17.sentence-1)

[ð](#itemdecl:17)

`template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI>
  requires [constant-iterator](const.iterators.alias#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]")<CI> && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<Iterator, CI>
constexpr operator CI() &&;
`

[18](#18)

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

*Returns*: std​::​move(*current_*)[.](#18.sentence-1)

[ð](#lib:operator%3c,basic_const_iterator)

`constexpr bool operator<(const basic_const_iterator& y) const
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
constexpr bool operator>(const basic_const_iterator& y) const
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
constexpr bool operator<=(const basic_const_iterator& y) const
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
constexpr bool operator>=(const basic_const_iterator& y) const
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
constexpr auto operator<=>(const basic_const_iterator& y) const
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<Iterator>;
`

[19](#19)

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

Let *op* be the operator[.](#19.sentence-1)

[20](#20)

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

*Effects*: Equivalent to:return *current_* *op* *y.current_*;

[ð](#lib:operator%3c,basic_const_iterator_)

`template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> I>
  constexpr bool operator<(const I& y) const
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> I>
  constexpr bool operator>(const I& y) const
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> I>
  constexpr bool operator<=(const I& y) const
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> I>
  constexpr bool operator>=(const I& y) const
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<basic_const_iterator> I>
  constexpr auto operator<=>(const I& y) const
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I> &&
             [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_­way_­comparable [cmp.concept]")<Iterator, I>;
`

[21](#21)

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

Let *op* be the operator[.](#21.sentence-1)

[22](#22)

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

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

[ð](#lib:operator%3c,basic_const_iterator__)

`template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") I>
  friend constexpr bool operator<(const I& x, const basic_const_iterator& y)
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") I>
  friend constexpr bool operator>(const I& x, const basic_const_iterator& y)
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") I>
  friend constexpr bool operator<=(const I& x, const basic_const_iterator& y)
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") I>
  friend constexpr bool operator>=(const I& x, const basic_const_iterator& y)
    requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator> && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]")<Iterator, I>;
`

[23](#23)

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

Let *op* be the operator[.](#23.sentence-1)

[24](#24)

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

*Effects*: Equivalent to: return x *op* y.*current_*;

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

`friend constexpr basic_const_iterator operator+(const basic_const_iterator& i, difference_type n)
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
friend constexpr basic_const_iterator operator+(difference_type n, const basic_const_iterator& i)
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
`

[25](#25)

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

*Effects*: Equivalent to: return basic_const_iterator(i.*current_* + n);

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

`friend constexpr basic_const_iterator operator-(const basic_const_iterator& i, difference_type n)
  requires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<Iterator>;
`

[26](#26)

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

*Effects*: Equivalent to: return basic_const_iterator(i.*current_* - n);

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

`template<[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Iterator> S>
  constexpr difference_type operator-(const S& y) const;
`

[27](#27)

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

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

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

`template<[not-a-const-iterator](const.iterators.iterator#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") S>
  requires [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<S, Iterator>
  friend constexpr difference_type operator-(const S& x, const basic_const_iterator& y);
`

[28](#28)

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

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