According to the C++23 standard, what is the output of this program?
#include <iostream>
#include <type_traits>
int main() {
std::cout << std::is_pointer_v<decltype(nullptr)>;
}This question asks if nullptr is a pointer. nullptr is a prvalue of type std::nullptr_t.
0
nullptr is a prvalue of type std::nullptr_t, which is not actually a pointer type. Instead, nullptr is a "null pointer constant" which can be converted to a pointer.
§[lex.nullptr]¶1 in the standard:
The pointer literal is the keyword
nullptr. It has typestd::nullptr_t.[Note 1:
std::nullptr_tis a distinct type that is neither a pointer type nor a pointer-to-member type; rather, a prvalue of this type is a null pointer constant and can be converted to a null pointer value or null member pointer value. See §[conv.ptr] and §[conv.mem]. — end note]