std::numeric_limits<T>:: is_integer
From cppreference.net
<
cpp
|
types
|
numeric limits
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type support
| Basic types | |||||||||||||||||||||
| Fixed width integer types (C++11) | |||||||||||||||||||||
| Fixed width floating-point types (C++23) | |||||||||||||||||||||
|
|||||||||||||||||||||
| Numeric limits | |||||||||||||||||||||
| C numeric limits interface | |||||||||||||||||||||
| Runtime type information | |||||||||||||||||||||
|
|||||||||||||||||||||
std::numeric_limits
| Static constants | ||||
|
numeric_limits::is_integer
|
||||
|
(C++11)
|
||||
| Static member functions | ||||
|
(C++11)
|
||||
| Helper types | ||||
|
static
const
bool
is_integer
;
|
(C++11 이전) | |
|
static
constexpr
bool
is_integer
;
|
(C++11 이후) | |
std::
numeric_limits
<
T
>
::
is_integer
의 값은 모든 정수 산술 타입
T
에 대해
true
이고, 그 외의 경우에는
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]
|
부호 있는 타입을 식별합니다
(public static member constant) |
|
[static]
|
정확한 타입을 식별합니다
(public static member constant) |
|
[static]
|
유한한 값들의 집합을 나타내는 타입을 식별합니다
(public static member constant) |