[ 2016-08-02, Chicago: Walt, Nevin, Rob, and Hal provide revised wording ]
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
This also resolves the first part of LWG 2460
In Table 46 — "Other transformations" edit the entry for common_type:
Table 46 — Other transformations Template Comments … template <class... T>
struct common_type;The member typedef type shall be defined or omitted as specified below.
If it is omitted, there shall be no member type. All types in the
parameter pack T shall be complete or (possibly cv) void.
A program may specialize this trait for two cv-unqualified non-reference types
if at least onetemplate parameter in the specializationof them
is a user-defined type. [Note: Such specializations are
needed when only explicit conversions are desired among the template
arguments. — end note]… Edit [meta.trans.other] p3 (and its subbullets) as shown below
For the common_type trait applied to a parameter pack T of types, the member type shall be either defined or not present as follows:
If sizeof...(T) is zero, there shall be no member type.
If sizeof...(T) is one, let T0 denote the sole type in the pack T. The member typedef type shall denote the same type as decay_t<T0>.
If sizeof...(T) is two, let
T1
andT2
, respectively, denote the first and second types comprisingT
, and letD1
andD2
, respectively, denotedecay_t<T1>
anddecay_t<T2>
.
If
is_same_v<T1, D1>
andis_same_v<T2, D2>
, and if there is no specializationcommon_type<T1, T2>
, letC
denote the type, if any, of an unevaluated conditional expression ([expr.cond]) whose first operand is an arbitrary value of typebool
, whose second operand is an xvalue of typeD1
, and whose third operand is an xvalue of typeD2
. If there is such a typeC
, the member typedeftype
shall denoteC
. Otherwise, there shall be no membertype
.If
not is_same_v<T1, D1>
ornot is_same_v<T2, D2>
, the member typedeftype
shall denote the same type, if any, as common_type_t<D1, D2>. Otherwise, there shall be no membertype
.If sizeof...(T) is greater than
onetwo, let T1, T2, and R, respectively, denote the first, second, and (pack of) remaining types comprising T.[Note: sizeof...(R) may be zero. — end note] Let C denote the type, if any, of an unevaluated conditional expression ([expr.cond]) whose first operand is an arbitrary value of type bool, whose second operand is an xvalue of type T1, and whose third operand is an xvalue of type T2.LetC
denotecommon_type_t<T1, T2>
. If there is such a type C, the member typedef type shall denote the same type, if any, as common_type_t<C, R...>. Otherwise, there shall be no member type.