首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::is_null_pointer

Defined in header <type_traits>

template< class T > struct is_null_pointer;

(since C++14)

检查是否T类型std::nullptr_t...

提供成员常量。value等于true,如果T类型std::nullptr_t,,,conststd::nullptr_t,,,volatilestd::nullptr_t,或constvolatilestd::nullptr_t...

否则,value等于false...

模板参数

T

-

a type to check

辅助变量模板

template< class T > inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value;

(since C++17)

继承自STD:积分[医]常量

成员常数

value static

true if T is the type std::nullptr_t (possibly cv-qualified) , false otherwise (public static member constant)

成员函数

operator bool

converts the object to bool, returns value (public member function)

operator() (C++14)

returns value (public member function)

成员类型

Type

Definition

value_type

bool

type

std::integral_constant<bool, value>

可能的实施

模板<class T>结构是[医]零[医]指针:std::is[医]相同<std::nullptr[医]t,type Name std::Remove[医]CV<T>*类型>{};

*。

注记

std::is_pointerfalsestd::nullptr_t因为它不是内置的指针类型。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
 
int main()
{
    std::cout << std::boolalpha
              << std::is_null_pointer< decltype(nullptr) >::value << ' '
              << std::is_null_pointer< int* >::value << '\n'
              << std::is_pointer< decltype(nullptr) >::value << ' '
              << std::is_pointer<int*>::value << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
true false
false true

二次

另见

is_void (C++11)

checks if a type is void (class template)

is_array (C++11)

checks if a type is an array type (class template)

is_pointer (C++11)

checks if a type is a pointer type (class template)

is_enum (C++11)

checks if a type is an enumeration type (class template)

is_union (C++11)

checks if a type is an union type (class template)

is_class (C++11)

checks if a type is a non-union class type (class template)

is_function (C++11)

checks if a type is a function type (class template)

is_object (C++11)

checks if a type is object type (class template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券