Eric Niebler wrote:
(This implements the specification in the latest C++17 draft.)
I'm not so sure. If a user defines a specialization for common_type
, it won't get used when computing common_type .
Interesting question. This is the specification:
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:
(3.1) β If sizeof...(T) is zero, there shall be no member type.
(3.2) β 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>.
(3.3) β If sizeof...(T) is greater than one, 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 (5.16) 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. If there
is such a type C, the member typedef type shall denote the same type, if
any, as common_type_t