• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    variable
    <limits>

    std::numeric_limits::is_exact

    // C++03
    static const bool is_exact;
    
    // C++11
    static constexpr bool is_exact;
    

    概要

    Tが正確(exact)な表現を持つ場合、is_exacttrueとなり、そうでない場合falseとなる。
    is_specialized == falseの場合はfalseとなる。

    #include <limits>
    
    int main()
    {
      constexpr bool a = std::numeric_limits<int>::is_exact;
      constexpr bool b = std::numeric_limits<char>::is_exact;
      constexpr bool c = std::numeric_limits<double>::is_exact;
    
      static_assert(a, "int must be exact");
      static_assert(b, "char must be exact");
      static_assert(!c, "double must be not exact");
    }
    

    出力