◐ Shell
clean mode source ↗

std::is_null_pointer - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template< class T > struct is_null_pointer;

(C++14以上)

Tstd::nullptr_t 型かどうか調べます。

Tstd::nullptr_tconst std::nullptr_tvolatile std::nullptr_t、またはconst volatile std::nullptr_t であれば、 true に等しいメンバ定数 value が提供されます。

そうでなければ、 valuefalse に等しくなります。

is_null_pointer または is_null_pointer_v (C++17以上) に対して特殊化を追加するプログラムは未定義です。

テンプレート引数

ヘルパー変数テンプレート

<tbody> </tbody>

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

(C++17以上)

std::integral_constant から継承

メンバ定数

Tstd::nullptr_t 型 (またはその cv 修飾された型)ならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
value を返します
(パブリックメンバ関数)

メンバ型

定義
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::nullptr_t は組み込みのポインタ型でないため、 std::is_pointerfalse を返します。

#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';
}

出力:

関連項目

(C++11)

型が void かどうか調べます
(クラステンプレート) [edit]

(C++11)

型が配列型かどうか調べます
(クラステンプレート) [edit]
型がポインタ型かどうか調べます
(クラステンプレート) [edit]

(C++11)

型が列挙型かどうか調べます
(クラステンプレート) [edit]

(C++11)

型が共用体型かどうか調べます
(クラステンプレート) [edit]

(C++11)

型がクラス型 (共用体を除く) かどうか調べます
(クラステンプレート) [edit]
型が関数型かどうか調べます
(クラステンプレート) [edit]

(C++11)

型がオブジェクト型かどうか調べます
(クラステンプレート) [edit]