[libcxx] r249737 - Factor definition of std::nullptr_t out of <cstddef> into a header that can also be used by <stddef.h>.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 13:34:11 PDT 2015
Author: rsmith
Date: Thu Oct 8 15:34:11 2015
New Revision: 249737
URL: http://llvm.org/viewvc/llvm-project?rev=249737&view=rev
Log:
Factor definition of std::nullptr_t out of <cstddef> into a header that can also be used by <stddef.h>.
Added:
libcxx/trunk/include/__nullptr
- copied, changed from r249736, libcxx/trunk/include/cstddef
Modified:
libcxx/trunk/include/cstddef
Copied: libcxx/trunk/include/__nullptr (from r249736, libcxx/trunk/include/cstddef)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__nullptr?p2=libcxx/trunk/include/__nullptr&p1=libcxx/trunk/include/cstddef&r1=249736&r2=249737&rev=249737&view=diff
==============================================================================
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/__nullptr Thu Oct 8 15:34:11 2015
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===--------------------------- cstddef ----------------------------------===//
+//===--------------------------- __nullptr --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,53 +8,19 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_CSTDDEF
-#define _LIBCPP_CSTDDEF
-
-/*
- cstddef synopsis
-
-Macros:
-
- offsetof(type,member-designator)
- NULL
-
-namespace std
-{
-
-Types:
-
- ptrdiff_t
- size_t
- max_align_t
- nullptr_t
-
-} // std
-
-*/
+#ifndef _LIBCPP_NULLPTR
+#define _LIBCPP_NULLPTR
#include <__config>
-#include <stddef.h>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::ptrdiff_t;
-using ::size_t;
-
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
-// Re-use the compiler's <stddef.h> max_align_t where possible.
-using ::max_align_t;
-#else
-typedef long double max_align_t;
-#endif
-
#ifdef _LIBCPP_HAS_NO_NULLPTR
+_LIBCPP_BEGIN_NAMESPACE_STD
+
struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
{
void* __lx;
@@ -86,11 +52,9 @@ inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CON
#define nullptr _VSTD::__get_nullptr_t()
-#endif // _LIBCPP_HAS_NO_NULLPTR
-
_LIBCPP_END_NAMESPACE_STD
-#ifndef _LIBCPP_HAS_NO_NULLPTR
+#else // _LIBCPP_HAS_NO_NULLPTR
namespace std
{
@@ -99,4 +63,4 @@ namespace std
#endif // _LIBCPP_HAS_NO_NULLPTR
-#endif // _LIBCPP_CSTDDEF
+#endif // _LIBCPP_NULLPTR
Modified: libcxx/trunk/include/cstddef
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=249737&r1=249736&r2=249737&view=diff
==============================================================================
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Oct 8 15:34:11 2015
@@ -34,6 +34,7 @@ Types:
*/
#include <__config>
+#include <__nullptr>
#include <stddef.h>
@@ -53,50 +54,6 @@ using ::max_align_t;
typedef long double max_align_t;
#endif
-#ifdef _LIBCPP_HAS_NO_NULLPTR
-
-struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
-{
- void* __lx;
-
- struct __nat {int __for_bool_;};
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
- _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
-
- template <class _Tp>
- _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
- operator _Tp* () const {return 0;}
-
- template <class _Tp, class _Up>
- _LIBCPP_ALWAYS_INLINE
- operator _Tp _Up::* () const {return 0;}
-
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;}
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;}
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;}
- friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;}
-};
-
-inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
-
-#define nullptr _VSTD::__get_nullptr_t()
-
-#endif // _LIBCPP_HAS_NO_NULLPTR
-
_LIBCPP_END_NAMESPACE_STD
-#ifndef _LIBCPP_HAS_NO_NULLPTR
-
-namespace std
-{
- typedef decltype(nullptr) nullptr_t;
-}
-
-#endif // _LIBCPP_HAS_NO_NULLPTR
-
#endif // _LIBCPP_CSTDDEF
More information about the cfe-commits
mailing list