在 Nicolai M. Josuttis 的《Cpp 标准库》第 2 版一书中,说 (5.4, p.125) struct common type 的定义如下:
template <typename T1, typename T2>
struct common_type<T1,T2> {
typedef decltype(true ? declval<T1>() : declval<T2>()) type;
};
我很难相信这是 common_type 的正确定义。原因:
typedef decltype(true ? declval<T1>() : declval<T2>()) type;//As far as I understand this will always pick second operand, declval<T1>(), due to the fact that there is 'true' value. Am I right?