std::is_null_pointer

Header: <type_traits>

std::is_null_pointer is a UnaryTypeTrait.

# Declarations

template< class T >
struct is_null_pointer;

(since C++11)

# Notes

std::is_pointer is false for std::nullptr_t because it is not a built-in pointer type.

In libc++, std::is_null_pointer is not available in C++11 mode.

# Example

#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()
{
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2247C++11the type trait for detecting std::nullptr_t was missingadded

# See also