std:: is_fundamental
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더 파일에 정의됨
<type_traits>
|
||
|
template
<
class
T
>
struct is_fundamental ; |
(C++11부터) | |
std::is_fundamental
는
UnaryTypeTrait
입니다.
만약
T
가
기본 타입
(즉, 산술 타입,
void
, 또는
nullptr_t
)인 경우, 멤버 상수
value
를
true
로 제공합니다. 다른 모든 타입에 대해서는
value
가
false
입니다.
프로그램이
std::is_fundamental
이나
std::is_fundamental_v
에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.
목차 |
템플릿 매개변수
| T | - | 확인할 타입 |
헬퍼 변수 템플릿
|
template
<
class
T
>
constexpr bool is_fundamental_v = is_fundamental < T > :: value ; |
(C++17부터) | |
std:: integral_constant 로부터 상속됨
멤버 상수
|
value
[static]
|
true
만약
T
가 기본 타입이면,
false
그렇지 않으면
(public static member constant) |
멤버 함수
|
operator bool
|
객체를
bool
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
가능한 구현
template<class T> struct is_fundamental : std::integral_constant< bool, std::is_arithmetic<T>::value || std::is_void<T>::value || std::is_same<std::nullptr_t, typename std::remove_cv<T>::type>::value // C++14에서는 대신 'std::is_null_pointer<T>::value'를 사용할 수도 있습니다 > {}; |
예제
#include <type_traits> static_assert(std::is_fundamental_v<int> == true); static_assert(std::is_fundamental_v<int&> == false); static_assert(std::is_fundamental_v<int*> == false); static_assert(std::is_fundamental_v<void> == true); static_assert(std::is_fundamental_v<void*> == false); static_assert(std::is_fundamental_v<float> == true); static_assert(std::is_fundamental_v<float&> == false); static_assert(std::is_fundamental_v<float*> == false); static_assert(std::is_fundamental_v<std::nullptr_t> == true); static_assert(std::is_fundamental_v<std::is_fundamental<int>> == false); class A {}; static_assert(std::is_fundamental_v<A> == false); static_assert(std::is_fundamental_v<std::is_fundamental<A>::value_type>); int main() {}
참고 항목
|
(C++11)
|
타입이 복합 타입인지 검사합니다
(클래스 템플릿) |
|
(C++11)
|
타입이 산술 타입인지 검사합니다
(클래스 템플릿) |
|
(C++11)
|
타입이
void
인지 검사합니다
(클래스 템플릿) |
|
(C++11)
(
DR*
)
|
타입이
std::nullptr_t
인지 검사합니다
(클래스 템플릿) |