std::numeric_limits<T>::is_integer
ja.cppreference.net より
static const bool is_integer;
|
(C++11未満) | |
static constexpr bool is_integer;
|
(C++11以上) | |
このstd::numeric_limits<T>::is_integerの値は、すべての整数演算型trueに対してはT、そうでない場合はfalseとなります。この定数はすべての特殊化において意味があります。
標準特殊化
T
|
std:: numeric_limits < T > :: is_integer の値 |
| /* non-specialized */ | false |
| bool | true |
| char | true |
| signed char | true |
| unsigned char | true |
| wchar_t | true |
| char8_t (C++20以降) | true |
| char16_t (C++11以降) | true |
| char32_t (C++11以降) | true |
| short | true |
| unsigned short | true |
| int | true |
| unsigned int | true |
| long | true |
| unsigned long | true |
| long long (C++11以降) | true |
| unsigned long long (C++11以降) | true |
| float | false |
| double | false |
| long double | false |
例
このコードを実行
#include <cstddef> #include <cstdint> #include <limits> 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<int*>::is_integer && !std::numeric_limits<float>::is_integer && !std::numeric_limits<double>::is_integer && !std::numeric_limits<long double>::is_integer && !std::numeric_limits<decltype([](){})>::is_integer // P0315R4 ); int main() {}
関連項目
|
(C++11)
|
型が整数型かどうかをチェックする
(クラステンプレート) |
|
[static]
|
符号付き型を識別する
(公開静的メンバ定数) |
|
[static]
|
正確な型を識別する
(公開静的メンバ定数) |
|
[static]
|
有限の値の集合を表す型を識別する
(公開静的メンバ定数) |