关于C++中common_type 的实现

template <typename T1, typename T2>

struct common_type<T1, T2> {
    typedef decltype(true ? declval<T1>() : declval<T2>()) type;
};

这个? : 语句中条件语句不是true吗, 那岂不是总是选第一个? 这个? : 有什么意义? 而实际测试中经常能得到第二个type...甚至除了这两个type以外的其他type.难道是我理解错误还是...求解释...谢谢.

https://segmentfault.com/q/1010000004098869

1+1.0 = 2.0

类型隐式转换。

因为?:表达式两个返回的类型是不一样的。会发生隐式转换。

最终就会变成那个可以同时表示T1 ,T2的 那个类别