簡體   English   中英

用戶定義類型的 is_floating_point 特化

[英]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;
}

沒有。 std::is_floating_point<T>定義為在“T 是浮點類型”時返回 true,然后標准聲明“存在三種浮點類型: floatdoublelong double

不留任何回旋余地。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM