为什么
a
是 true
,b
是 false
?或者换句话说,为什么 foo1
中的 T
是 int const
,但 foo2
的返回类型只是 int
?template<typename T>
constexpr bool foo1(T &) {
return std::is_const<T>::value;
}
template<typename T>
T foo2(T &);
int main() {
int const x = 0;
constexpr bool a = foo1(x);
constexpr bool b = std::is_const<decltype(foo2(x))>::value;
}