std::ranges::iterator_t, std::ranges::const_iterator_t, std::ranges::sentinel_t, std::ranges::const_sentinel_t

Header: <ranges>

  1. Used to obtain the iterator type of the type T.

# Declarations

template< class T >
using iterator_t = decltype(ranges::begin(std::declval<T&>()));

(since C++20)

template< ranges::range R >
using const_iterator_t = decltype(ranges::cbegin(std::declval<R&>()));

(since C++23)

template< ranges::range R >
using sentinel_t = decltype(ranges::end(std::declval<R&>()));

(since C++20)

template< ranges::range R >
using const_sentinel_t = decltype(ranges::cend(std::declval<R&>()));

(since C++23)

# Notes

iterator_t can be applied to non-range types, e.g. arrays with unknown bound.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3946C++23const_iterator_t and const_sentinel_t were inconsistentwith the result of ranges::cbegin and ranges::cend respectivelytweaked

# See also