std::nullptr_t
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <cstddef> | ||
typedef decltype(nullptr) nullptr_t; | (dal C++11) | |
std::nullptr_t è il tipo di puntatore nullo letterale, 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.
[modifica]Esempio
Se due o più sovraccarichi accettare diversi tipi di puntatore, un sovraccarico per std::nullptr_t è necessario accettare un argomento puntatore nullo .
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
[modifica]Vedi anche
nullptr | il puntatore letterale che specifica un valore nullo (C++11) valore del puntatore 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. |
implementazione definita puntatore nullo costante 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. (macro costante) |