Differences between std::is_integer and std::is_integral?

后端 未结 5 1861
粉色の甜心
粉色の甜心 2021-01-01 10:02

C++11 provides two type trait template classes: std::is_integer and std::is_integral. However, I cannot tell the differences between them.

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 10:09

    There is no type T that has different results for std::is_integral::value and std::numeric_limits::is_integer. To quote the draft Standard:

    3.9.1 Fundamental types [basic.fundamental]

    7 Types bool, char, char16_t, char32_t, wchar_t, and the signed and unsigned integer types are collectively called integral types. A synonym for integral type is integer type.[...]

    18.3.2.4 numeric_limits members [numeric.limits.members]

    static constexpr bool is_integer;
    

    17 True if the type is integer.

    20.9.4.1 Primary type categories [meta.unary.cat] (table 47)

    template  struct is_integral;
    

    T is an integral type (3.9.1)

提交回复
热议问题