Namespaces
Variants

std::numeric_limits<T>:: has_infinity

From cppreference.net
Utilities library
static const bool has_infinity ;
(C++11 이전)
static constexpr bool has_infinity ;
(C++11 이후)

std:: numeric_limits < T > :: has_infinity 의 값은 양의 무한대를 별도의 특수 값으로 표현할 수 있는 모든 타입 T 에 대해 true 입니다. 이 상수는 모든 부동소수점 타입에 의미가 있으며, std:: numeric_limits < T > :: is_iec559 == true 인 경우 반드시 true 가 보장됩니다.

표준 특수화

T std:: numeric_limits < T > :: has_infinity 의 값
/* non-specialized */ false
bool false
char false
signed char false
unsigned char false
wchar_t false
char8_t (C++20부터) false
char16_t (C++11부터) false
char32_t (C++11부터) false
short false
unsigned short false
int false
unsigned int false
long false
unsigned long false
long long (C++11부터) false
unsigned long long (C++11부터) false
float 일반적으로 true
double 일반적으로 true
long double 일반적으로 true

예제

#include <iostream>
#include <limits>
int main()
{
    std::cout << std::boolalpha
              << std::numeric_limits<int>::has_infinity << '\n'
              << std::numeric_limits<long>::has_infinity << '\n'
              << std::numeric_limits<float>::has_infinity << '\n'
              << std::numeric_limits<double>::has_infinity << '\n';
}

가능한 출력:

false
false
true
true

참고 항목

[static]
주어진 부동소수점 타입의 양의 무한대 값을 반환합니다
(public static member function)
특수 값 "quiet not-a-number"(NaN)을 표현할 수 있는 부동소수점 타입을 식별합니다
(public static member constant)
특수 값 "signaling not-a-number"(NaN)을 표현할 수 있는 부동소수점 타입을 식별합니다
(public static member constant)