std::indirectly_readable_traits
<iterator>
struct indirectly_readable_traits<T*> :
requires std::is_array_v <I>
struct indirectly_readable_traits<I>;
struct indirectly_readable_traits<const T> :
struct indirectly_readable_traits<T> :
struct indirectly_readable_traits<T> :
requires /* has-member-element-type */<T>
requires /* has-member-element-type */<T> &&
std::same_as <std::remove_cv_t <typename T::element_type>,
std::remove_cv_t <typename T::value_type>>
struct indirectly_readable_traits<T> :
requires std::is_object_v <T>
struct /* cond-value-type */ <T>
concept /* has-member-value-type */ =
concept /* has-member-element-type */ =
Computes the associated value type of the template argument. If the associated value type exists, it is represented by the nested type value_type, otherwise value_type is not defined. A program may specialize indirectly_readable_traits for a program-defined type.
The specializations above can be informally described as below.
Given a type T, its associated value type V is determined as follows:
T is const-qualified, V is the associated value type of const-unqualified T.
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 types value_type and element_type:
C is typename T::value_type.
C is undefined.
T has the nested type value_type but not element_type, C is typename T::value_type.
T has the nested type element_type but not value_type, C is typename T::element_type.
C is undefined.
V is determined from C as follows:
C is undefined, or C is not an object type, V is undefined.
V is cv-unqualified C.
value_type is intended for use with indirectly_readable types such as iterators. It is not intended for use with ranges.
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 and element_type nested types
|
added specialization (8) |
| LWG 3541 | C++20 | LWG 3446 introduced hard error for ambiguous cases that value_type and element_type are different
|
added specialization (7) |