Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::common_reference< Ts > Class Template Reference

A trait which determines the common reference type for a set of types. More...

Detailed Description

template<typename... Ts>
class arene::base::common_reference< Ts >

A trait which determines the common reference type for a set of types.

Template Parameters
TsThe types for which to determine the common reference.

The common reference type is defined as follows:

  • If sizeof...(Ts) is 0, type is not defined.
  • If sizeof...(Ts) is 1, type names the only type in the pack.
  • If sizeof...(Ts) is 2, the following alternatives are considered in order:
    • Let R be COMMON-REF(T0,T1). If T0 and T1 are reference types, R is well-formed, and both pointer-conversion checks to R succeed, type names R.
    • Otherwise, if basic_common_reference<remove_cvref_t<T0>,remove_cvref_t<T1>,T0Qual,T1Qual>::type is defined, type names that type.
    • Otherwise, if COND-RES(T0,T1) is well-formed, type names that type.
    • Otherwise, if std::common_type_t<T0,T1> is well-formed, type names that type.
    • Otherwise, type is not defined.
  • If sizeof...(Ts) is greater than 2, let C be common_reference_t<T0,T1>. If C is well-formed, type names the type of common_reference<C,Ts...>; otherwise, type is not defined.

The exposition-only COMMON-REF(A,B) operation is defined as follows. Let X and Y be the results of applying remove_reference_t to A and B, respectively. Let CREF(A) be a const lvalue reference to X, COPYCV(FROM,TO) be TO with the top-level cv-qualifiers of FROM, and COND-RES(X,Y) be decltype(false ? std::declval<X(&)()>()() : std::declval<Y(&)()>()()).

  • If A and B are both lvalue reference types, COMMON-REF(A,B) is COND-RES(COPYCV(X,Y)&,COPYCV(Y,X)&) if that type exists and is a reference type.
  • If A and B are both rvalue reference types, let C be remove_reference_t<COMMON-REF(X&,Y&)>&&. If C is well-formed and both types are convertible to C, COMMON-REF(A,B) is C.
  • If A is an rvalue reference and B is an lvalue reference, let D be COMMON-REF(CREF(X),Y&). If D is well-formed and A is convertible to D, COMMON-REF(A,B) is D.
  • If A is an lvalue reference and B is an rvalue reference, COMMON-REF(A,B) is COMMON-REF(B,A).
  • Otherwise, COMMON-REF(A,B) is not defined.

The documentation for this class was generated from the following file: