![](/img/trans.png)
[英]std::is_floating_point returns false for float in some cases
[英]is_floating_point specialization for user defined type
我可以為用戶定義的 class 定義 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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.