std::experi...::value_type(3)
π std::experi...::value_type(3) π
okay so this is straight from the C++ Standard Libary manual, and the main character is std::experimental::ranges::value_type β¨
πΈ NAME πΈ
std::experimental::ranges::value_type β std::experimental::ranges::value_type
yes bestie, thatβs the same name twice; the manpage said it like that and Iβm not gonna pretend otherwise π
π¦ Synopsis π¦
Defined in header <experimental/ranges/iterator>
template< class I > (1)
struct value_type {};
template< class T > (2)
struct value_type<T*>;
template< class I >
requires std::is_array<I>::value (3)
struct value_type<I> : value_type<std::decay_t<I>> {};
template< class T > (4)
struct value_type<const T> : value_type<std::decay_t<T>> {};
template< class T >
requires requires { typename T::value_type; } (5)
struct value_type<T>;
template< class T >
requires requires { typename T::element_type; } (6)
struct value_type<T>;
So whatβs the vibe? It computes the associated value type of the type I, if any. And yes, users may specialize value_type for a program-defined type π«Ά
Hereβs the numbered rundown, no cap:
- (1) β the primary template is an empty struct. Literally
struct value_type {};and nothing else. - (2) β specialization for pointers. If
Tis an object type, it provides a member typetypeequal tostd::remove_cv_t<T>. Otherwise, there is no member type. - (3) β specialization for array types. The code is
struct value_type<I> : value_type<std::decay_t<I>> {};underrequires std::is_array<I>::value. - (4) β specialization for const-qualified types. The code is
struct value_type<const T> : value_type<std::decay_t<T>> {};. - (5) β specialization for types that define a public and accessible member type
value_type. IfT::value_typeis an object type, it provides a member typetypeequal toT::value_type. Otherwise, there is no member type. - (6) β specialization for types that define a public and accessible member type
element_type(e.g.,std::shared_ptr). IfT::element_typeis an object type, it provides a member typetypeequal tostd::remove_cv_t<typename T::element_type>. Otherwise, there is no member type.
π¦ Notes π¦
β οΈ bestie, listen: if a type contains both avalue_typemember and aelement_typemember, then the specializations (5) and (6) are ambiguous. Thatβs the drama.
value_type is intended for use with Readable types such as iterators. It is not intended for use with ranges.
π Example π
π§ This section is incomplete Reason: no example
not me showing up with an empty example section π but thatβs literally what the page says.
π See also π
Readable(concept) β specifies that a type is readable by applyingoperator *.iterator_traits(alias template) β compatibility traits class that collects an iteratorβs associated types.
π Category: π
* Todo no example
okay thatβs the whole page, bestie π«Ά source/version vibes from http://cppreference.com, dated 2024.06.10, and the footer signature is std::experi...::value_type(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