std::nullptr_t
提供:cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <cstddef>
|
||
| typedef decltype(nullptr) nullptr_t; |
(C + + 11以来) | |
std::nullptr_tリテラルNULLポインタの一種である、nullptr.
Original:
std::nullptr_t is 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.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
2つ以上のオーバーロードが異なるポインタ型を受け入れた場合、std::nullptr_tためのオーバーロードがヌルポインタ引数を承諾する必要があります.
Original:
If two or more overloads accept different pointer types, an overload for std::nullptr_t is necessary to accept a null pointer argument.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <cstddef> #include <iostream> void f(int* pi) { std::cout << "Pointer to integer overload\n"; } void f(double* pd) { std::cout << "Pointer to double overload\n"; } void f(std::nullptr_t nullp) { std::cout << "null pointer overload\n"; } int main() { int* pi; double* pd; f(pi); f(pd); f(nullptr); // would be ambiguous without void f(nullptr_t) // f(NULL); // ambiguous overload: all three functions are candidates }
Output:
Pointer to integer overload Pointer to double overload null pointer overload
[編集] も参照してください
| nullptrを | ヌルポインタ値(C++11)を指定するリテラルのポインタ
Original: the pointer literal which specifies a null pointer value (C++11) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| 実装定義のヌルポインタ定数 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. (マクロ定数) | |