std::ranges::iterator_t, std::ranges::const_iterator_t, std::ranges::sentinel_t, std::ranges::const_sentinel_t
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
computes the associated types of an iterator
(alias template)[edit]
iterator_tconst_iterator_tsentinel_tconst_sentinel_t
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
Defined in header
<ranges>
template< class T >
using iterator_t = decltype(ranges::begin (std::declval <T&>()));
(1)
(since C++20)
using iterator_t = decltype(ranges::begin (std::declval <T&>()));
template< ranges::range R >
using const_iterator_t = decltype(ranges::cbegin (std::declval <R&>()));
(2)
(since C++23)
using const_iterator_t = decltype(ranges::cbegin (std::declval <R&>()));
template< ranges::range R >
using sentinel_t = decltype(ranges::end (std::declval <R&>()));
(3)
(since C++20)
using sentinel_t = decltype(ranges::end (std::declval <R&>()));
template< ranges::range R >
using const_sentinel_t = decltype(ranges::cend (std::declval <R&>()));
(4)
(since C++23)
using const_sentinel_t = decltype(ranges::cend (std::declval <R&>()));
1) Used to obtain the iterator type of the type
T
.3) Used to obtain the sentinel type of the range type
R
.4) Used to obtain the constant sentinel type of the range type
R
.[edit] Template parameters
T
-
a type that can be used in std::ranges::begin
R
-
a
range
type or a sized_range
type
[edit] Notes
iterator_t
can be applied to non-range types, e.g. arrays with unknown bound.
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3946 | C++23 | const_iterator_t and const_sentinel_t were inconsistentwith the result of ranges::cbegin and ranges::cend respectively
|
tweaked |
[edit] See also
(C++20)(C++20)(C++23)(C++20)(C++20)(C++20)
(alias template)[edit]