The Wayback Machine - https://web.archive.org/web/20180304232717/http://ja.cppreference.com:80/w/cpp/language/nullptr
名前空間
変種
操作

nullptr pointer literal

提供: cppreference.com
< cpp‎ | language

 
 
C++言語
一般的なトピック
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外指定(廃止予定)
noexcept 指定子(C++11)
例外
名前空間
指定子
decltype(C++11)
auto(C++11)
alignas(C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr(C++11)
ユーザ定義(C++11)
ユーティリティ
アトリビュート(C++11)
typedef 宣言
型エイリアス宣言(C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 

目次

[編集]構文

nullptr(C++11およびそれ以降)

[編集]説明

キーワードnullptr、リテラルNULLポインタを表します。それは型の不特定prvaluestd::nullptr_tです。任意のポインタ型とメンバの型へのポインタのポインタの値をnullに<div class="t-tr-text">暗黙の型変換
Original:
implicit conversions
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
からnullptr存在する。似たような変換は、タイプstd::nullptr_tの任意の値に対してだけでなく、マクロNULL、nullポインタ定数のために存在している.
Original:
The keyword nullptr denotes the null pointer literal. It is an unspecified prvalue of type std::nullptr_t. There exist
暗黙の型変換
Original:
implicit conversions
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
</div>
from nullptr to null pointer value of any pointer type and any pointer to member type. Similar conversions exist for any value of type std::nullptr_t as well as for the macro NULL, the null pointer constant.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

nullptrを、テンプレート関数を介して転送することができる方法を示しています.
Original:
Demonstrates how nullptr allows forwarding via a template function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <cstddef>#include <iostream>   template<class F, class A>void Fwd(F f, A a){ f(a);}   void g(int* i){std::cout<<"Function g called\n";}   int main(){ g(NULL);// Fine g(0);// Fine   Fwd(g, nullptr);// Fine// Fwd(g, NULL); // ERROR: No function g(int)}

出力:

Function g called Function g called Function g called

[編集]キーワード

nullptr

[編集]参照

実装定義のヌルポインタ定数
Original:
implementation-defined null pointer constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(マクロ定数)[edit]
(C++11)
nullポインタリテラルnullptrの型
Original:
the type of the null pointer literal nullptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(typedef)[edit]
close