#include <iostream>
#include <type_traits>
struct A {
template <typename T>
A(std::enable_if_t<std::is_floating_point<T>::value, T> f) { }
};
int main() {
std::cout << (std::is_floating_point<double>::value) << std::endl; // true
A v1((double)2.2);
return 0;
}发布于 2019-01-01 03:33:56
在构造函数中,T在non-deduced context中。它不能从参数中推导出来(对于构造函数,也不能显式指定)。
https://stackoverflow.com/questions/53990836
复制相似问题