std::nullptr_t - cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Definido no cabeçalho <cstddef> |
||
|
|
(desde C++11) | |
std::nullptr_t é o tipo de ponteiro nulo literal, 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.
Exemplo
Se dois ou mais sobrecargas aceitar tipos diferentes de ponteiro, uma sobrecarga para std::nullptr_t é necessário aceitar um argumento de ponteiro nulo .
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.
#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 }
Saída:
Pointer to integer overload Pointer to double overload null pointer overload
Veja também
| nullptr | o ponteiro literal que especifica um valor nulo (C++11) ponteiro Original: the pointer literal which specifies a null pointer value (C++11) The text has been machine-translated via Google Translate. |
definida pela implementação ponteiro nulo constante Original: implementation-defined null pointer constant The text has been machine-translated via Google Translate. (macro constante) [edit] | |