• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    variable
    <limits>

    std::numeric_limits::is_integer

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

    概要

    Tが整数型であるならis_integertrueとなり、そうでなければfalseとなる。
    is_specialized == falseの場合、falseとなる。

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

    出力