
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<MyInt, int>, it won't get used when computing common_type<MyInt, int, int>.
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<C,R...>. Otherwise, there shall be no member type. I'd say that this is what I implemented. But you do have a point that it doesn't do what yours does.