
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>.
As it turns out, users are not allowed to specialize common_type, which is why the C++17 specification does not concern itself with such specializations. As a curiosity, decaying the arguments before the conditional operator is also subtly wrong. #include <iostream> #include <typeinfo> struct X { operator int (); operator long () const; }; struct Y { operator int (); operator long () const; }; int main() { std::cout << typeid( true? declval<X const&>(): declval<Y const&>() ).name() << std::endl; std::cout << typeid( true? declval<X&>(): declval<Y&>() ).name() << std::endl; std::cout << typeid( true? declval<X>(): declval<Y>() ).name() << std::endl; }