名前空間
変種

std::is_null_pointer

提供: cppreference.com
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
型サポート
型の性質
(C++11)
(C++11)
(C++14)
(C++11)
(C++11)(C++20未満)
(C++11)(C++20で非推奨)
(C++11)
型特性定数
メタ関数
(C++17)
定数評価文脈
サポートされている操作
関係と性質の問い合わせ
型変更
(C++11)(C++11)(C++11)
型変換
(C++11)
(C++11)
(C++17)
(C++11)(C++20未満)(C++17)
 
<tbody> </tbody>
ヘッダ <type_traits> で定義
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以上) に対して特殊化を追加するプログラムは未定義です。

テンプレート引数

T - 調べる型

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

<tbody> </tbody>
template< class T > inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value;
(C++17以上)

std::integral_constant から継承

メンバ定数

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

メンバ関数

operator bool
オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
operator()
(C++14)
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';
}

出力:

true false
false true

関連項目

(C++11)
型が void かどうか調べます
(クラステンプレート) [edit]
(C++11)
型が配列型かどうか調べます
(クラステンプレート) [edit]
型がポインタ型かどうか調べます
(クラステンプレート) [edit]
(C++11)
型が列挙型かどうか調べます
(クラステンプレート) [edit]
(C++11)
型が共用体型かどうか調べます
(クラステンプレート) [edit]
(C++11)
型がクラス型 (共用体を除く) かどうか調べます
(クラステンプレート) [edit]
型が関数型かどうか調べます
(クラステンプレート) [edit]
(C++11)
型がオブジェクト型かどうか調べます
(クラステンプレート) [edit]