std::numeric_limits<T>::is_integer
提供: cppreference.com
< cpp | types | numeric limits
staticconstbool is_integer; | (C++11未満) | |
staticconstexprbool is_integer; | (C++11以上) | |
std::numeric_limits<T>::is_integer の値は、すべての整数算術型に対しては true になり、そうでなければ false になります。 この定数はすべての特殊化について意味があります。
[編集]標準の特殊化
T | std::numeric_limits<T>::is_integer の値 |
/* 非特殊化 */ | false |
bool | true |
char | true |
signedchar | true |
unsignedchar | true |
wchar_t | true |
char8_t(C++20) | true |
char16_t(C++11) | true |
char32_t(C++11) | true |
short | true |
unsignedshort | true |
int | true |
unsignedint | true |
long | true |
unsignedlong | true |
longlong(C++11) | true |
unsignedlonglong(C++11) | true |
float | false |
double | false |
longdouble | false |
[編集]例
Run this code
#include <cstddef>#include <cstdint>#include <numeric> int main(){ static_assert(std::numeric_limits<bool>::is_integer&&std::numeric_limits<std::size_t>::is_integer&&std::numeric_limits<std::int32_t>::is_integer&&std::numeric_limits<std::int64_t>::is_integer&&std::numeric_limits<decltype(42)>::is_integer&&!std::numeric_limits<float>::is_integer&&!std::numeric_limits<double>::is_integer&&!std::numeric_limits<longdouble>::is_integer&&!std::numeric_limits<decltype([](){})>::is_integer// P0315R4);}
[編集]関連項目
(C++11) | 型が整数型かどうか調べます (クラステンプレート) |
[静的] | 符号付きの型を識別します (パブリック静的メンバ定数) |
[静的] | 正確な型を識別します (パブリック静的メンバ定数) |
[静的] | 値の有限集合を表現する型を識別します (パブリック静的メンバ定数) |