std::numeric_limits<T>::is_integer
提供: cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
static const bool is_integer; |
(C++11未満) | |
static constexpr bool is_integer; |
(C++11以上) | |
std::numeric_limits<T>::is_integer の値は、すべての整数算術型に対しては true になり、そうでなければ false になります。 この定数はすべての特殊化について意味があります。
標準の特殊化
T
|
std::numeric_limits<T>::is_integer の値
|
| /* 非特殊化 */ | 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
|
例
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<long double>::is_integer
&& !std::numeric_limits<decltype([](){})>::is_integer // P0315R4
);
}
関連項目
(C++11) |
型が整数型かどうか調べます (クラステンプレート) |
[静的] |
符号付きの型を識別します (パブリック静的メンバ定数) |
[静的] |
正確な型を識別します (パブリック静的メンバ定数) |
[静的] |
値の有限集合を表現する型を識別します (パブリック静的メンバ定数) |