[const.iterators.iterator]

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

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

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

#### 24.5.3.3 Class template basic_const_iterator [const.iterators.iterator]

namespace std {template<class I>concept [*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<const iter_value_t<I>&&, iter_rvalue_reference_t<I>>; 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<Iterator>; // *exposition only*using *rvalue-reference* = // *exposition only**iter-const-rvalue-reference-t*<Iterator>; public:using iterator_concept = *see below*; using iterator_category = *see below*; // not always presentusing value_type = iter_value_t<Iterator>; using difference_type = iter_difference_t<Iterator>;

 basic_const_iterator() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<Iterator> = default; constexpr basic_const_iterator(Iterator current); 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); 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); constexpr const Iterator& base() const & noexcept; constexpr Iterator base() &&; constexpr *reference* operator*() const; constexpr const auto* operator->() constrequires 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>; 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]")<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>; 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>; 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>; 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]")<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; 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*](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 &; 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*](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() &&; 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]")<Iterator>; 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]")<Iterator>; 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]")<Iterator>; 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]")<Iterator>; 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]")<Iterator> && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<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) constrequires [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) constrequires [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) constrequires [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) constrequires [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) constrequires [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>; 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]")<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*](#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*](#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*](#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>; 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>; 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>; 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; 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]")<S, Iterator>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](#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[.](#1.sentence-1)
