std::nullptr_t (3) - Linux Manuals
std::nullptr_t: std::nullptr_t
Command to display std::nullptr_t
manual in Linux: $ man 3 std::nullptr_t
NAME
std::nullptr_t - std::nullptr_t
Synopsis
Defined in header <cstddef>
typedef decltype(nullptr) nullptr_t; (since C++11)
std::nullptr_t is the type of the null pointer literal, nullptr. It is a distinct type that is not itself a pointer type or a pointer to member type.
Example
If two or more overloads accept different pointer types, an overload for std::nullptr_t is necessary to accept a null pointer argument.
// Run this code
#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(0); // ambiguous call: all three functions are candidates
// f(NULL); // ambiguous if NULL is an integral null pointer constant
// (as is the case in most implementations)
}
Output:
Pointer to integer overload
Pointer to double overload
null pointer overload
See also
nullptr the pointer literal which specifies a null pointer value (C++11)
implementation-defined null pointer constant
NULL (macro constant)
is_null_pointer checks if a type is std::nullptr_t
(class template)
(C++14)
Pages related to std::nullptr_t
- std::nullopt (3) - std::nullopt
- std::nullopt_t (3) - std::nullopt_t
- std::num_get (3) - std::num_get
- std::num_get<CharT,InputIt>::get,std::num_get<CharT,InputIt>::do_get (3) - std::num_get<CharT,InputIt>::get,std::num_get<CharT,InputIt>::do_get
- std::num_get<CharT,InputIt>::num_get (3) - std::num_get<CharT,InputIt>::num_get
- std::num_get<CharT,InputIt>::~num_get (3) - std::num_get<CharT,InputIt>::~num_get
- std::num_put (3) - std::num_put
- std::num_put<CharT,OutputIt>::num_put (3) - std::num_put<CharT,OutputIt>::num_put
- std::num_put<CharT,OutputIt>::put,std::num_put<CharT,OutputIt>::do_put (3) - std::num_put<CharT,OutputIt>::put,std::num_put<CharT,OutputIt>::do_put
- std::num_put<CharT,OutputIt>::~num_put (3) - std::num_put<CharT,OutputIt>::~num_put
- std::numeric_limits (3) - std::numeric_limits