Namespaces
Variants

std:: is_null_pointer

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
is_null_pointer
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더에 정의됨 <type_traits>
template < class T >
struct is_null_pointer ;
(C++11부터)

std::is_null_pointer UnaryTypeTrait 입니다.

T std::nullptr_t 타입인지 확인합니다.

T std::nullptr_t , const std:: nullptr_t , volatile std:: nullptr_t , 또는 const volatile std:: nullptr_t 타입인 경우, value 멤버 상수를 true 값으로 제공합니다.

그렇지 않으면, value false 와 같습니다.

프로그램이 std::is_null_pointer 또는 std::is_null_pointer_v (C++17부터) 에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.

목차

템플릿 매개변수

T - 확인할 타입

헬퍼 변수 템플릿

template < class T >
constexpr bool is_null_pointer_v = is_null_pointer < T > :: value ;
(C++17부터)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T std::nullptr_t 타입인 경우 (cv-qualified 가능), 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_null_pointer : std::is_same<std::nullptr_t, std::remove_cv_t<T>> {};

참고 사항

std::is_pointer false 를 반환합니다. std::nullptr_t 의 경우, 이것이 내장 포인터 타입이 아니기 때문입니다.

libc++에서, std::is_null_pointer 는 C++11 모드에서 사용할 수 없습니다.

기능 테스트 매크로 표준 기능
__cpp_lib_is_null_pointer 201309L (C++14)
(DR11)
std::is_null_pointer

예제

#include <type_traits>
static_assert(std::is_null_pointer_v<decltype(nullptr)>);
static_assert(!std::is_null_pointer_v<int*>);
static_assert(!std::is_pointer_v<decltype(nullptr)>);
static_assert(std::is_pointer_v<int*>);
int main()
{
}

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2247 C++11 std::nullptr_t 를 감지하는 타입 트레이트가 누락됨 추가됨

참고 항목

(C++11)
타입이 void 인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 배열 타입인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 포인터 타입인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 열거형 타입인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 공용체 타입인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 비공용체 클래스 타입인지 검사합니다
(클래스 템플릿)
타입이 함수 타입인지 검사합니다
(클래스 템플릿)
(C++11)
타입이 객체 타입인지 검사합니다
(클래스 템플릿)