[libcxx-commits] [PATCH] D114786: [libc++] Remove the ability to use the std::nullptr_t emulation in C++03 mode

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 24 17:14:38 PST 2022


Quuxplusone added inline comments.


================
Comment at: libcxx/include/stddef.h:48
 #ifdef __cplusplus
-
-extern "C++" {
-#include <__nullptr>
-using std::nullptr_t;
-}
-
+    typedef decltype(nullptr) nullptr_t;
 #endif
----------------
@JamesNagurne @ldionne : Whoa, yeah. Shouldn't this be
```
#ifdef __cplusplus
namespace std { using nullptr_t = decltype(nullptr); }
#endif
```
and that's all? Also, what was this ever doing in C's <stddef.h>? It should go in <cstddef> instead.
If we want to preserve libc++'s historical behavior, it seems it would be
```
// in <cstddef>
namespace std { using nullptr_t = decltype(nullptr); }

// in <stddef.h>
namespace std { using nullptr_t = decltype(nullptr); }
using std::nullptr_t;
```
(Yes, including the same `using nullptr_t = decltype(nullptr);` token-sequence twice in a row is actually fine with C++ these days. I checked that at least GCC trunk's C++11 mode and MSVC latest's C++11 mode are happy with it.)
But, if we want to do the most sensible thing regardless of backward compatibility, I think it would be
```
// in <cstddef>
namespace std { using nullptr_t = decltype(nullptr); }

// in <stddef.h>
/* nothing at all */
```

I propose to leave this to @ldionne to address, unless he delegates it back to me. :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114786/new/

https://reviews.llvm.org/D114786



More information about the libcxx-commits mailing list