std::is_null_pointer
提供: cppreference.com
ヘッダ <type_traits> で定義
|
||
template< class T > struct is_null_pointer; |
(C++14以上) | |
T
が std::nullptr_t 型かどうか調べます。
T
が std::nullptr_t、const std::nullptr_t、volatile std::nullptr_t、またはconst volatile std::nullptr_t であれば、 true に等しいメンバ定数 value
が提供されます。
そうでなければ、 value
は false に等しくなります。
is_null_pointer
または is_null_pointer_v
(C++17以上) に対して特殊化を追加するプログラムは未定義です。
目次 |
[編集] テンプレート引数
T | - | 調べる型 |
[編集] ヘルパー変数テンプレート
template< class T > inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value; |
(C++17以上) | |
std::integral_constant から継承
メンバ定数
value [静的] |
T が std::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_pointer は false を返します。
[編集] 例
Run this code
#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 かどうか調べます (クラステンプレート) |
(C++11) |
型が配列型かどうか調べます (クラステンプレート) |
(C++11) |
型がポインタ型かどうか調べます (クラステンプレート) |
(C++11) |
型が列挙型かどうか調べます (クラステンプレート) |
(C++11) |
型が共用体型かどうか調べます (クラステンプレート) |
(C++11) |
型がクラス型 (共用体を除く) かどうか調べます (クラステンプレート) |
(C++11) |
型が関数型かどうか調べます (クラステンプレート) |
(C++11) |
型がオブジェクト型かどうか調べます (クラステンプレート) |