std::experi...on_reference(3)
π NAME π
okay so this page is std::experi...on_reference(3) from the C++ Standard Libary manual β yes, the header is literally truncated like that, and yes, βLibaryβ is spelled like that on the page, we are keeping it ππ
The NAME section literally repeats it twice: std::experimental::ranges::common_reference β std::experimental::ranges::common_reference. Iconic duplicate behavior, no notes.
β¨ Synopsis β¨
Defined in header <experimental/ranges/type_traits>:
template< class... T > (ranges TS)
struct common_reference;
So common_reference determines the common reference type of the types T... β that is, the type to which all the types in T... can be converted or bound. If such a type exists (as determined according to the rules below), the member type names that type. Otherwise, there is no member type. And bestie, the behavior is undefined if any of the types in T... is an incomplete type other than (possibly cv-qualified) void. Undefined behavior is not the vibe π©
When given reference types, common_reference attempts to find a reference type to which the supplied reference types can all be bound, but may return a non-reference type if it cannot find such a reference type.
The rules, in order:
- If
sizeof...(T)is zero, there is no member type. - If
sizeof...(T)is one (i.e.,T...contains only one typeT0), the member type names the same type asT0. - If
sizeof...(T)is two (i.e.,T...contains two typesT1andT2):- If
T1andT2are both reference types, and the simple common reference typeSofT1andT2(as defined below) exists, then the member typetypenamesS; - Otherwise, if
basic_common_reference<T1R, T2R, T1Q, T2Q>::typeexists, whereTiRisstd::remove_cv_t<std::remove_reference_t<Ti>>andTiQis an alias template such thatTiQ<TiR>isTi, then the member typetypenames that type; - Otherwise, if
decltype(false? val<T1>() : val<T2>()), wherevalis a function templatetemplate<class T> T val();, denotes a valid type, then the member typetypenames that type; - Otherwise, if
ranges::common_type_t<T1, T2>is a valid type, then the member typetypenames that type; - Otherwise, there is no member type.
- If
- If
sizeof...(T)is greater than two (i.e.,T...consists of the typesT1,T2,R...), then ifranges::common_reference_t<T1, T2>exists, the member type denotesranges::common_reference_t<ranges::common_reference_t<T1, T2>, R...>if such a type exists. In all other cases, there is no member type.
The simple common reference type of two reference types T1 and T2 is defined as follows:
- If
T1iscv1 X &andT2iscv2 Y &(i.e., both are lvalue reference types): their simple common reference type isdecltype(false? std::declval<cv12 X &>() : std::declval<cv12 Y &>()), wherecv12is the union ofcv1andcv2, if that type exists and is a reference type. - If
T1andT2are both rvalue reference types: if the simple common reference type ofT1 &andT2 &(determined according to the previous bullet) exists, then letCdenote that type's corresponding rvalue reference type. Ifstd::is_convertible<T1, C>::valueandstd::is_convertible<T2, C>::valueare bothtrue, then the simple common reference type ofT1andT2isC. - Otherwise, one of the two types must be an lvalue reference type
A &and the other must be an rvalue reference typeB &&(AandBmight be cv-qualified). LetDdenote the simple common reference type ofA &andB const &, if any. IfDexists andstd::is_convertible<B &&, D>::valueistrue, then the simple common reference type isD. - Otherwise, there's no simple common reference type.
π«Ά Member types π«Ά
- Name:
type - Definition: the common reference type for all
T...
π§ Helper types π§
template< class... T >
using common_reference_t = typename common_reference<T...>::type;
template< class T, class U, template<class> class TQual,
template<class> class
UQual >
struct basic_common_reference {};
The class template basic_common_reference is a customization point that allows users to influence the result of common_reference for user-defined types (typically proxy references). The primary template is empty.
π₯ Specializations π₯
A program may specialize basic_common_reference<T, U, TQual, UQual> on the first two parameters T and U if std::is_same<T, std::decay_t<T>> and std::is_same<U, std::decay_t<U>> are both true and at least one of them depends on a program-defined type.
If such a specialization has a member named type, it must be a public and unambiguous member type that names a type to which both TQual<T> and UQual<U> are convertible. Additionally, ranges::basic_common_reference<T, U, TQual, UQual>::type and ranges::basic_common_reference<U, T, UQual, TQual>::type must denote the same type.
A program may not specialize basic_common_reference on the third or fourth parameters, nor may it specialize common_reference itself. A program that adds specializations in violation of these rules has undefined behavior. Like, do not do that, bestie π«π
πΈ Notes πΈ
This section is incomplete. The page said it, not me π
π Example π
This section is incomplete. Reason: no example π«
π See also π
common_typeβ determines the common type of a group of types(C++11)(class template)common_typeβ determine the common type of a set of types(class template)CommonReferenceβ specifies that two types share a common reference type(concept)
π Categories π
- Todo without reason
- Todo no example
okay that's the page π source: http://cppreference.com, version/date: 2024.06.10, and the footer title is std::experi...on_reference(3) β bye bestie, go slay some common reference types β¨π
π¦ 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