std::indire...dable_traits(3)
π NAME π
std::indirectly_readable_traits β std::indirectly_readable_traits. Thatβs the name section, bestie, and yes, itβs giving βiconic but slightly mysterious.β The page header is std::indire...dable_traits(3), from the C++ Standard Libary (yes, that spelling is on the page β weβre not fixing it π
).
This one computes the associated value type of the template argument. If that associated value type exists, itβs 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. Periodt.
β¨ Synopsis β¨
Defined in header <iterator>.
The declarations are all here, bestie β no cap, not one skipped:
template< class I > (1)
(since C++20)
struct indirectly_readable_traits {};
template< class T >
struct indirectly_readable_traits<T*> : (2)
(since C++20)
/* cond-value-type */<T> {};
template< class I >
requires std::is_array_v<I>
struct indirectly_readable_traits<I>; (3)
(since C++20)
{ using value_type =
std::remove_cv_t<std::remove_extent_t<I>>; }
template< class T >
struct indirectly_readable_traits<const T> : (4)
(since C++20)
indirectly_readable_traits<T> {};
template< /* has-member-value-type */ T >
struct indirectly_readable_traits<T> : (5)
(since C++20)
/* cond-value-type */<typename T::value_type> {};
template< /* has-member-element-type */ T >
struct indirectly_readable_traits<T> : (6)
(since C++20)
/* cond-value-type */<typename T::element_type> {};
template< /* has-member-value-type */ T >
requires /* has-member-element-type */<T> (7)
(since C++20)
struct indirectly_readable_traits<T> {};
template< /* has-member-value-type */ T >
requires /* has-member-element-type */<T> &&
std::same_as<std::remove_cv_t<typename
T::element_type>, (8)
(since C++20)
std::remove_cv_t<typename
T::value_type>>
struct indirectly_readable_traits<T> :
/* cond-value-type */<typename T::value_type> {};
β¨ Helper classes and concepts β¨
These are the exposition-only besties, iykyk:
template< class > (1)
(exposition only*)
struct /* cond-value-type */ {};
template< class T >
requires std::is_object_v<T> (2)
(exposition only*)
struct /* cond-value-type */ <T>
{ using value_type = std::remove_cv_t<T>; };
template< class T >
concept /* has-member-value-type */ = (3)
(exposition only*)
requires { typename T::value_type; };
template< class T >
concept /* has-member-element-type */ = (4)
(exposition only*)
requires { typename T::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.
π§ Explanation π§
The specializations above can be informally described as below.
Given a type T, its associated value type V is determined as follows:
- If
Tis const-qualified,Vis the associated value type of const-unqualifiedT. - Otherwise, if
Tis an array type,Vis the cv-unqualified array element type. - Otherwise, a conditional value type
Cis determined first:- If
Tis a pointer type,Cis the pointed-to type. - Otherwise, if
Thas nested typesvalue_typeandelement_type:- If these types are the same (not considering cv-qualification),
Cistypename T::value_type. - Otherwise,
Cis undefined.
- If these types are the same (not considering cv-qualification),
- Otherwise, if
Thas the nested typevalue_typebut notelement_type,Cistypename T::value_type. - Otherwise, if
Thas the nested typeelement_typebut notvalue_type,Cistypename T::element_type. - Otherwise,
Cis undefined.
- If
- Then
Vis determined fromCas follows:- If
Cis undefined, orCis not an object type,Vis undefined. - Otherwise,
Vis cv-unqualifiedC.
- If
π Notes π
value_type is intended for use with indirectly_readable types such as iterators. It is not intended for use with ranges. Thatβs the whole note, bestie β important little vibe check π«Ά.
π§ͺ Example π§ͺ
This section is incomplete Reason: no example
No example yet, so weβre not gonna invent one. We donβt do fanfic in the manual page π.
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR 3446, applied to C++20. Behavior as published: specializations
(5,6)were ambiguous for types having bothvalue_typeandelement_typenested types. Correct behavior: added specialization(8). - DR 3541, applied to C++20. Behavior as published: LWG 3446 introduced hard error for ambiguous cases that
value_typeandelement_typeare different. Correct behavior: added specialization(7).
π See also π
indirectly_readable(C++20) β specifies that a type is indirectly readable by applyingoperator *(concept).iter_value_t(C++20) β computes the associated types of an iterator (alias template).iter_reference_t(C++20) β computes the associated types of an iterator (alias template).iter_const_reference_t(C++23) β computes the associated types of an iterator (alias template).iter_difference_t(C++20) β computes the associated types of an iterator (alias template).iter_rvalue_reference_t(C++20) β computes the associated types of an iterator (alias template).iter_common_reference_t(C++20) β computes the associated types of an iterator (alias template).iterator_traitsβ provides uniform interface to the properties of an iterator (class template).
π·οΈ Category π·οΈ
Todo no example
Okay bestie, thatβs the whole page π From the footer: source http://cppreference.com, version/date 2024.06.10, and the manual name std::indire...dable_traits(3) β mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms