std::indirectly_readable_traits
Min standard notice:
Header: <iterator>
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.
# Declarations
template< class I >
struct indirectly_readable_traits {};
(since C++20)
template< class T >
struct indirectly_readable_traits<T*> :
/* cond-value-type */<T> {};
(since C++20)
template< class I >
requires std::is_array_v<I>
struct indirectly_readable_traits<I>;
{ using value_type = std::remove_cv_t<std::remove_extent_t<I>>; }
(since C++20)
template< class T >
struct indirectly_readable_traits<const T> :
indirectly_readable_traits<T> {};
(since C++20)
template< /* has-member-value-type */ T >
struct indirectly_readable_traits<T> :
/* cond-value-type */<typename T::value_type> {};
(since C++20)
template< /* has-member-element-type */ T >
struct indirectly_readable_traits<T> :
/* cond-value-type */<typename T::element_type> {};
(since C++20)
template< /* has-member-value-type */ T >
requires /* has-member-element-type */<T>
struct indirectly_readable_traits<T> {};
(since C++20)
template< /* has-member-value-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> :
/* cond-value-type */<typename T::value_type> {};
(since C++20)
Helper classes and concepts
template< class >
struct /* cond-value-type */ {};
(exposition only*)
template< class T >
requires std::is_object_v<T>
struct /* cond-value-type */ <T>
{ using value_type = std::remove_cv_t<T>; };
(exposition only*)
template< class T >
concept /* has-member-value-type */ =
requires { typename T::value_type; };
(exposition only*)
template< class T >
concept /* has-member-element-type */ =
requires { typename T::element_type; };
(exposition only*)
# Notes
value_type is intended for use with indirectly_readable types such as iterators. It is not intended for use with ranges.
# Example
This section is incompleteReason: no example
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3446 | C++20 | specializations (5,6) were ambiguous for types havingboth value_type and element_type nested types | added specialization (8) |
| LWG 3541 | C++20 | LWG 3446 introduced hard error for ambiguous casesthat value_type and element_type are different | added specialization (7) |