Iterators
Collaboration diagram for Iterators:

## Modules

| Iterator Tags

## Classes

struct | std::input_iterator_tag
struct | std::iterator_traits< _Iterator >

## Macros

#define | __cpp_lib_make_reverse_iterator

## Functions

template<bool _IsMove, typename _CharT >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, ostreambuf_iterator< _CharT > >::__type | std::__copy_move_a2 (_CharT *__first, _CharT *__last, ostreambuf_iterator< _CharT > __result)
template<bool _IsMove, typename _CharT >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, ostreambuf_iterator< _CharT > >::__type | std::__copy_move_a2 (const _CharT *__first, const _CharT *__last, ostreambuf_iterator< _CharT > __result)
template<bool _IsMove, typename _CharT >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, _CharT * >::__type | std::__copy_move_a2 (istreambuf_iterator< _CharT > __first, istreambuf_iterator< _CharT > __last, _CharT *__result)
template<typename _CharT , typename _Size >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, _CharT * >::__type | std::__copy_n_a (istreambuf_iterator< _CharT > __it, _Size __n, _CharT *__result, bool __strict)
template<typename _Iter >
constexpr iterator_traits< _Iter >::iterator_category | std::__iterator_category (const _Iter &)
template<typename _Iterator , typename _ReturnType = __conditional_t<__move_if_noexcept_cond <typename iterator_traits<_Iterator>::value_type>::value, _Iterator, move_iterator<_Iterator>>>
constexpr _ReturnType | std::__make_move_if_noexcept_iterator (_Iterator __i)
template<typename _Tp , typename _ReturnType = __conditional_t<__move_if_noexcept_cond<_Tp>::value, const _Tp*, move_iterator<_Tp*>>>
constexpr _ReturnType | std::__make_move_if_noexcept_iterator (_Tp *__i)
template<typename _Iterator >
constexpr reverse_iterator< _Iterator > | std::__make_reverse_iterator (_Iterator __i)
template<typename _Iterator >
constexpr auto | std::__miter_base (reverse_iterator< _Iterator > __it) -> decltype(__make_reverse_iterator(__miter_base(__it.base())))
template<typename _Iterator >
constexpr auto | std::__niter_base (reverse_iterator< _Iterator > __it) -> decltype(__make_reverse_iterator(__niter_base(__it.base())))
template<typename _CharT , typename _Distance >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, void >::__type | std::advance (istreambuf_iterator< _CharT > &__i, _Distance __n)
template<typename _Container >
constexpr back_insert_iterator< _Container > | std::back_inserter (_Container &__x)
template<typename _CharT >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, ostreambuf_iterator< _CharT > >::__type | std::copy (istreambuf_iterator< _CharT > __first, istreambuf_iterator< _CharT > __last, ostreambuf_iterator< _CharT > __result)
template<typename _CharT >
__gnu_cxx::__enable_if< __is_char< _CharT >::__value, istreambuf_iterator< _CharT > >::__type | std::find (istreambuf_iterator< _CharT > __first, istreambuf_iterator< _CharT > __last, const _CharT &__val)
template<typename _Container >
constexpr front_insert_iterator< _Container > | std::front_inserter (_Container &__x)
template<typename _Container >
constexpr insert_iterator< _Container > | std::inserter (_Container &__x, std::__detail::__range_iter_t< _Container > __i)
template<typename _Iterator >
constexpr move_iterator< _Iterator > | std::make_move_iterator (_Iterator __i)
template<typename _Iterator >
constexpr reverse_iterator< _Iterator > | std::make_reverse_iterator (_Iterator __i)
template<typename _Iterator >
constexpr bool | std::operator!= (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator!= (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator!= (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<typename _Iterator >
constexpr move_iterator< _Iterator > | std::operator+ (typename move_iterator< _Iterator >::difference_type __n, const move_iterator< _Iterator > &__x)
template<typename _Iterator >
constexpr reverse_iterator< _Iterator > | std::operator+ (typename reverse_iterator< _Iterator >::difference_type __n, const reverse_iterator< _Iterator > &__x)
template<typename _IteratorL , typename _IteratorR >
constexpr auto | std::operator- (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) -> decltype(__x.base() - __y.base())
template<typename _IteratorL , typename _IteratorR >
constexpr auto | std::operator- (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) -> decltype(__y.base() - __x.base())
template<typename _Iterator >
constexpr bool | std::operator< (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator< (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) requires requires
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator< (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<typename _Iterator >
constexpr bool | std::operator<= (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator<= (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) requires requires
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator<= (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<three_way_comparable _Iterator>
constexpr compare_three_way_result_t< _Iterator, _Iterator > | std::operator<=> (const reverse_iterator< _Iterator > &__x, const reverse_iterator< _Iterator > &__y)
template<typename _IteratorL , three_way_comparable_with< _IteratorL > _IteratorR>
constexpr compare_three_way_result_t< _IteratorL, _IteratorR > | std::operator<=> (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
template<typename _CharT , typename _Traits >
bool | std::operator== (const istreambuf_iterator< _CharT, _Traits > &__a, const istreambuf_iterator< _CharT, _Traits > &__b)
template<typename _Iterator >
constexpr bool | std::operator== (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator== (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) requires requires
template<typename _Iterator >
constexpr bool | std::operator== (const reverse_iterator< _Iterator > &__x, const reverse_iterator< _Iterator > &__y) requires requires
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator== (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<typename _Iterator >
constexpr bool | std::operator> (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator> (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) requires requires
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator> (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<typename _Iterator >
constexpr bool | std::operator>= (const move_iterator< _Iterator > &__x, const move_iterator< _Iterator > &__y)
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator>= (const move_iterator< _IteratorL > &__x, const move_iterator< _IteratorR > &__y) requires requires
template<typename _IteratorL , typename _IteratorR >
constexpr bool | std::operator>= (const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y) requires requires
template<input_or_output_iterator _It, sentinel_for< _It > _Sent>
| std::requires (!same_as< _It, _Sent >) &&copyable< _It > class common_iterator
template<typename _Iterator1 , typename _Iterator2 >
| std::requires (!sized_sentinel_for< _Iterator1, _Iterator2 >) inline const expr bool disable_sized_sentinel_for< reverse_iterator< _Iterator1 >

## Variables

| std::reverse_iterator< _Iterator2 >

## Detailed Description

Abstractions for uniform iterating through various underlying types.

## Function Documentation

## __iterator_category()

template<typename _Iter >

constexpr iterator_traits<_Iter>::iterator_category std::__iterator_category | ( | const _Iter & |  | ) |

inline constexpr

This function is not a part of the C++ standard but is syntactic sugar for internal library use only.

Definition at line 238 of file stl_iterator_base_types.h.

Referenced by std::deque< _Tp, _Alloc >::deque(), std::vector< _Tp, _Alloc >::vector(), __gnu_debug::__valid_range_aux(), std::advance(), std::deque< _Tp, _Alloc >::assign(), std::distance(), and std::deque< _Tp, _Alloc >::insert().

## back_inserter()

template<typename _Container >

constexpr back_insert_iterator<_Container> std::back_inserter | ( | _Container & | __x | ) |

inline constexpr

Parameters

  __x | A container of arbitrary type.

Returns
  An instance of back_insert_iterator working on `__x`.

This wrapper function helps in creating back_insert_iterator instances. Typing the name of the iterator requires knowing the precise full type of the container, which can be tedious and impedes generic programming. Using this function lets you take advantage of automatic template parameter deduction, making the compiler match the correct types for you.

Definition at line 781 of file bits/stl_iterator.h.

Referenced by std::match_results< _Bi_iter, _Alloc >::format(), and std::regex_replace().

## front_inserter()

template<typename _Container >

constexpr front_insert_iterator<_Container> std::front_inserter | ( | _Container & | __x | ) |

inline constexpr

Parameters

  __x | A container of arbitrary type.

Returns
  An instance of front_insert_iterator working on `x`.

This wrapper function helps in creating front_insert_iterator instances. Typing the name of the iterator requires knowing the precise full type of the container, which can be tedious and impedes generic programming. Using this function lets you take advantage of automatic template parameter deduction, making the compiler match the correct types for you.

Definition at line 882 of file bits/stl_iterator.h.

## inserter()

template<typename _Container >

constexpr insert_iterator<_Container> std::inserter | ( | _Container & | __x,
|  | std::__detail::__range_iter_t< _Container > | __i
| ) |  |

constexpr

Parameters

  __x | A container of arbitrary type.
  __i | An iterator into the container.

Returns
  An instance of insert_iterator working on `__x`.

This wrapper function helps in creating insert_iterator instances. Typing the name of the iterator requires knowing the precise full type of the container, which can be tedious and impedes generic programming. Using this function lets you take advantage of automatic template parameter deduction, making the compiler match the correct types for you.

Definition at line 1016 of file bits/stl_iterator.h.

## make_reverse_iterator()

template<typename _Iterator >

constexpr reverse_iterator<_Iterator> std::make_reverse_iterator | ( | _Iterator | __i | ) |

inline constexpr

Generator function for reverse_iterator.

Definition at line 650 of file bits/stl_iterator.h.

## operator==()

template<typename _IteratorL , typename _IteratorR >

constexpr bool std::operator== | ( | const reverse_iterator< _IteratorL > & | __x,
|  | const reverse_iterator< _IteratorR > & | __y
| ) |  |

constexpr

Parameters

  __x | A reverse_iterator.
  __y | A reverse_iterator.

Returns
  A simple bool.

Reverse iterators forward comparisons to their underlying base() iterators.

Definition at line 530 of file bits/stl_iterator.h.

## requires()

template<input_or_output_iterator _It, sentinel_for< _It > _Sent>

std::requires | ( | !same_as< _It, _Sent > |  | ) | &&

An iterator/sentinel adaptor for representing a non-common range.

Definition at line 1851 of file bits/stl_iterator.h.

References std::__addressof(), std::forward(), std::move(), and std::operator*().