我可以为用户定义的类定义is_floating_point吗?我试过了。但是is_floating_point返回false。
class Test
{
public:
Test() { x = 0; }
private:
float x;
};
template<>
struct is_floating_point<Test>
{
static constexpr bool value = true;
};
void main()
{
std::cout<<std::is_floating_point<Test>::value<<endl;
}发布于 2020-12-16 00:33:15
不是的。当"T是浮点类型“时,std::is_floating_point<T>为defined,返回true,然后标准返回states,”有三种浮点类型:float、double和long double。
不会留下任何回旋余地。
https://stackoverflow.com/questions/65309782
复制相似问题