Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Defined in header <iterator> | ||
template<class I> struct indirectly_readable_traits{}; | (1) | (since C++20) |
template<class T> struct indirectly_readable_traits<T*>: | (2) | (since C++20) |
template<class I> requiresstd::is_array_v<I> | (3) | (since C++20) |
template<class T> struct indirectly_readable_traits<const T>: | (4) | (since C++20) |
template</* has-member-value-type */ T> struct indirectly_readable_traits<T>: | (5) | (since C++20) |
template</* has-member-element-type */ T> struct indirectly_readable_traits<T>: | (6) | (since C++20) |
template</* has-member-value-type */ T> requires/* has-member-element-type */<T> | (7) | (since C++20) |
template</* has-member-value-type */ T> requires/* has-member-element-type */<T>&& | (8) | (since C++20) |
Helper classes and concepts | ||
template<class> struct/* cond-value-type */{}; | (1) | (exposition only*) |
template<class T> requiresstd::is_object_v<T> | (2) | (exposition only*) |
template<class T> concept/* has-member-value-type */= | (3) | (exposition only*) |
template<class T> concept/* has-member-element-type */= | (4) | (exposition only*) |
Computes the associated value type of the template argument. If the associated value type exists, it is represented by the nested typevalue_type
, otherwisevalue_type
is not defined. A program may specializeindirectly_readable_traits
for aprogram-defined type.
Contents |
The specializations above can be informally described as below.
Given a typeT
, its associated value typeV
is determined as follows:
T
is const-qualified,V
is the associated value type of const-unqualifiedT
.T
is an array type,V
is the cv-unqualified array element type.C
is determined first:T
is a pointer type,C
is the pointed-to type.T
has nested typesvalue_type
andelement_type
:C
istypename T::value_type
.C
is undefined.T
has the nested typevalue_type
but notelement_type
,C
istypename T::value_type
.T
has the nested typeelement_type
but notvalue_type
,C
istypename T::element_type
.C
is undefined.V
is determined fromC
as follows:C
is undefined, orC
is not anobject type,V
is undefined.V
is cv-unqualifiedC
.value_type
is intended for use withindirectly_readable
types such as iterators. It is not intended for use with ranges.
This section is incomplete Reason: no example |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3446 | C++20 | specializations(5,6) were ambiguous for types having both value_type andelement_type nested types | added specialization(8) |
LWG 3541 | C++20 | LWG 3446 introduced hard error for ambiguous cases that value_type andelement_type are different | added specialization(7) |
(C++20) | specifies that a type is indirectly readable by applying operator* (concept)[edit] |
(C++20)(C++20)(C++23)(C++20)(C++20)(C++20) | computes the associated types of an iterator (alias template)[edit] |
provides uniform interface to the properties of an iterator (class template)[edit] |