[const.iterators] # 24 Iterators library [[iterators]](./#iterators) ## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#const.iterators) ### 24.5.3 Constant iterators and sentinels [const.iterators] #### [24.5.3.1](#general) General [[const.iterators.general]](const.iterators.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4179) Class template basic_const_iterator is an iterator adaptor with the same behavior as the underlying iterator except that its indirection operator implicitly converts the value returned by the underlying iterator's indirection operator to a type such that the adapted iterator is a constant iterator ([[iterator.requirements]](iterator.requirements "24.3 Iterator requirements"))[.](#general-1.sentence-1) Some generic algorithms can be called with constant iterators to avoid mutation[.](#general-1.sentence-2) [2](#general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4188) Specializations of basic_const_iterator are constant iterators[.](#general-2.sentence-1) #### [24.5.3.2](#alias) Alias templates [[const.iterators.alias]](const.iterators.alias) [🔗](#concept:constant-iterator) `template<[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") It> using [iter_const_reference_t](#lib:iter_const_reference_t "24.5.3.2 Alias templates [const.iterators.alias]") = common_reference_t&&, iter_reference_t>; template concept [constant-iterator](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]") = // exposition only [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]"), iter_reference_t>; template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") I> using [const_iterator](#lib:const_iterator "24.5.3.2 Alias templates [const.iterators.alias]") = see below; ` [1](#alias-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4207) *Result*: If I models [*constant-iterator*](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]"), I[.](#alias-1.sentence-1) Otherwise, basic_const_iterator[.](#alias-1.sentence-2) [🔗](#alias-itemdecl:2) `template<[semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") S> using [const_sentinel](#lib:const_sentinel "24.5.3.2 Alias templates [const.iterators.alias]") = see below; ` [2](#alias-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4219) *Result*: If S models [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]"), const_iterator[.](#alias-2.sentence-1) Otherwise, S[.](#alias-2.sentence-2) #### [24.5.3.3](#iterator) Class template basic_const_iterator [[const.iterators.iterator]](const.iterators.iterator) namespace std {templateconcept [*not-a-const-iterator*](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") = *see below*; // *exposition only*template<[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") I>using *iter-const-rvalue-reference-t* = // *exposition only* common_reference_t&&, iter_rvalue_reference_t>; template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") Iterator>class [basic_const_iterator](#lib:basic_const_iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") { Iterator *current_* = Iterator(); // *exposition only*using *reference* = iter_const_reference_t; // *exposition only*using *rvalue-reference* = // *exposition only**iter-const-rvalue-reference-t*; public:using iterator_concept = *see below*; using iterator_category = *see below*; // not always presentusing value_type = iter_value_t; using difference_type = iter_difference_t; basic_const_iterator() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]") = default; constexpr basic_const_iterator(Iterator current); template<[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]") U>constexpr basic_const_iterator(basic_const_iterator current); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") T>requires [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")constexpr basic_const_iterator(T&& current); constexpr const Iterator& base() const & noexcept; constexpr Iterator base() &&; constexpr *reference* operator*() const; constexpr const auto* operator->() constrequires is_lvalue_reference_v> &&[same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")>, value_type>; constexpr basic_const_iterator& operator++(); constexpr void operator++(int); 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]"); constexpr basic_const_iterator& operator--() requires [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]"); 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]"); 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]"); 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]"); constexpr *reference* operator[](difference_type n) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"); template<[sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]") S>constexpr bool operator==(const S& s) const; template<[*not-a-const-iterator*](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI>requires [*constant-iterator*](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]") && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")constexpr operator CI() const &; template<[*not-a-const-iterator*](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI>requires [*constant-iterator*](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]") && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")constexpr operator CI() &&; constexpr bool operator<(const basic_const_iterator& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"); constexpr bool operator>(const basic_const_iterator& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"); constexpr bool operator<=(const basic_const_iterator& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"); constexpr bool operator>=(const basic_const_iterator& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"); constexpr auto operator<=>(const basic_const_iterator& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]"); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") I>constexpr bool operator<(const I& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") I>constexpr bool operator>(const I& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") I>constexpr bool operator<=(const I& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") I>constexpr bool operator>=(const I& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") I>constexpr auto operator<=>(const I& y) constrequires [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]") &&[three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_­way_­comparable [cmp.concept]"); template<[*not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[*not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); 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]"); 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]"); 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]"); template<[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]") S>constexpr difference_type operator-(const S& y) const; template<[*not-a-const-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]")friend constexpr difference_type operator-(const S& x, const basic_const_iterator& y); friend constexpr *rvalue-reference* iter_move(const basic_const_iterator& i)noexcept(noexcept(static_cast<*rvalue-reference*>(ranges::iter_move(i.*current_*)))){return static_cast<*rvalue-reference*>(ranges::iter_move(i.*current_*)); }};} [1](#iterator-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4353) Given some type I, the concept [*not-a-const-iterator*](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") is defined as false if I is a specialization of basic_const_iterator andtrue otherwise[.](#iterator-1.sentence-1) #### [24.5.3.4](#types) Member types [[const.iterators.types]](const.iterators.types) [1](#types-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4361) basic_const_iterator​::​iterator_concept is defined as follows: - [(1.1)](#types-1.1) If Iterator models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_­iterator [iterator.concept.contiguous]"), then iterator_concept denotes contiguous_iterator_tag[.](#types-1.1.sentence-1) - [(1.2)](#types-1.2) Otherwise, if Iterator models [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"), then iterator_concept denotes random_access_iterator_tag[.](#types-1.2.sentence-1) - [(1.3)](#types-1.3) Otherwise, if Iterator models [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]"), then iterator_concept denotes bidirectional_iterator_tag[.](#types-1.3.sentence-1) - [(1.4)](#types-1.4) Otherwise, if Iterator models [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]"), then iterator_concept denotes forward_iterator_tag[.](#types-1.4.sentence-1) - [(1.5)](#types-1.5) Otherwise, iterator_concept denotes input_iterator_tag[.](#types-1.5.sentence-1) [2](#types-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4380) The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") iterator_category is defined if and only if Iterator models [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]")[.](#types-2.sentence-1) In that case,basic_const_iterator​::​iterator_category denotes the type iterator_traits<​Iterator>​::​iterator_category[.](#types-2.sentence-2) #### [24.5.3.5](#ops) Operations [[const.iterators.ops]](const.iterators.ops) [🔗](#lib:basic_const_iterator,constructor) `constexpr basic_const_iterator(Iterator current); ` [1](#ops-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4395) *Effects*: Initializes *current_* with std​::​move(current)[.](#ops-1.sentence-1) [🔗](#lib:basic_const_iterator,constructor_) `template<[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]") U> constexpr basic_const_iterator(basic_const_iterator current); ` [2](#ops-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4407) *Effects*: Initializes *current_* with std​::​move(current.*current_*)[.](#ops-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]") T> requires [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]") constexpr basic_const_iterator(T&& current); ` [3](#ops-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4421) *Effects*: Initializes *current_* with std​::​forward(current)[.](#ops-3.sentence-1) [🔗](#lib:base,basic_const_iterator) `constexpr const Iterator& base() const & noexcept; ` [4](#ops-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](#ops-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](#ops-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> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")>, value_type>; ` [7](#ops-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_*)[.](#ops-7.sentence-1) [🔗](#lib:operator++,basic_const_iterator) `constexpr basic_const_iterator& operator++(); ` [8](#ops-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](#ops-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]"); ` [10](#ops-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]"); ` [11](#ops-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]"); ` [12](#ops-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]"); 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]"); ` [13](#ops-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4557) Let *op* be the operator[.](#ops-13.sentence-1) [14](#ops-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]") ` [15](#ops-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]") S> constexpr bool operator==(const S& s) const; ` [16](#ops-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4587) *Effects*: Equivalent to: return *current_* == s; [🔗](#ops-itemdecl:16) `template<[not-a-const-iterator](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI> requires [constant-iterator](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]") && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]") constexpr operator CI() const &; ` [17](#ops-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4599) *Returns*: *current_*[.](#ops-17.sentence-1) [🔗](#ops-itemdecl:17) `template<[not-a-const-iterator](#concept:not-a-const-iterator "24.5.3.3 Class template basic_­const_­iterator [const.iterators.iterator]") CI> requires [constant-iterator](#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]") && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]") constexpr operator CI() &&; ` [18](#ops-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4611) *Returns*: std​::​move(*current_*)[.](#ops-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]"); 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]"); 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]"); 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]"); 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]") && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]"); ` [19](#ops-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4635) Let *op* be the operator[.](#ops-19.sentence-1) [20](#ops-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]") 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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") 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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") 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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") 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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") 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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]") && [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_­way_­comparable [cmp.concept]"); ` [21](#ops-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4669) Let *op* be the operator[.](#ops-21.sentence-1) [22](#ops-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](#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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); template<[not-a-const-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]") && [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"); ` [23](#ops-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4697) Let *op* be the operator[.](#ops-23.sentence-1) [24](#ops-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]"); 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]"); ` [25](#ops-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]"); ` [26](#ops-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]") S> constexpr difference_type operator-(const S& y) const; ` [27](#ops-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](#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]") friend constexpr difference_type operator-(const S& x, const basic_const_iterator& y); ` [28](#ops-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L4751) *Effects*: Equivalent to: return x - y.*current_*;