From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/types%2Fnullptr_t.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 devdocs/c/types%2Fnullptr_t.html (limited to 'devdocs/c/types%2Fnullptr_t.html') diff --git a/devdocs/c/types%2Fnullptr_t.html b/devdocs/c/types%2Fnullptr_t.html new file mode 100644 index 00000000..ea058783 --- /dev/null +++ b/devdocs/c/types%2Fnullptr_t.html @@ -0,0 +1,32 @@ +

nullptr_t

Defined in header <stddef.h>
typedef typeof(nullptr) nullptr_t;
+
(since C23)

nullptr_t is the type of the predefined null pointer constant, nullptr. It is a distinct type that is not itself a pointer type. It can be implicitly converted to any pointer type or bool, and the result is the null pointer value of that type or false respectively. No type other than nullptr_t itself can be converted or explicitly cast to nullptr_t.

+

sizeof(nullptr_t) and alignof(nullptr_t) are equal to sizeof(void*) and alignof(void*) respectively.

+

nullptr_t has only one valid value, i.e., nullptr. The object representation of nullptr is same as that of (void*)0. If a program produces a nullptr_t value with a different object representation, the behavior is undefined.

+

Example

+

Demonstrate that nullptr_t is a distinct type.

+
#include <stddef.h>
+#include <stdio.h>
+ 
+#define DETECT_NULL_POINTER_CONSTANT(e) \
+    _Generic(e,                         \
+        void* : puts("void*"),          \
+        nullptr_t : puts("nullptr_t"),  \
+        default : puts("other")       \
+    )
+ 
+int main()
+{
+    DETECT_NULL_POINTER_CONSTANT(((void*)0));
+    DETECT_NULL_POINTER_CONSTANT(0);
+    DETECT_NULL_POINTER_CONSTANT(nullptr);
+}

Output:

+
void*
+other
+nullptr_t

See also

+ +
implementation-defined null pointer constant
(macro constant)
C++ documentation for nullptr_t
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/types/nullptr_t +

+
-- cgit v1.2.3