From 46e9493c687004357f757d08335c3ec411a361fd Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 7 Jul 2012 20:56:04 +0000 Subject: [PATCH] Appy constexpr to . Picked up a few missing noexcepts as well. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159902 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/memory | 39 +++++++++++++++++++++++++-------------- include/tuple | 4 ++++ src/memory.cpp | 1 + 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/memory b/include/memory index 0f3ccec5..b181bc9d 100644 --- a/include/memory +++ b/include/memory @@ -2467,7 +2467,11 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> template struct _LIBCPP_VISIBLE default_delete { - _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} +#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} +#endif template _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, typename enable_if::value>::type* = 0) _NOEXCEPT {} @@ -2482,7 +2486,11 @@ template struct _LIBCPP_VISIBLE default_delete<_Tp[]> { public: - _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} +#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} +#endif template _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} @@ -2520,13 +2528,13 @@ private: typedef typename remove_reference::type& _Dp_reference; typedef const typename remove_reference::type& _Dp_const_reference; public: - _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) { static_assert(!is_pointer::value, "unique_ptr constructed with null function pointer deleter"); } - _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) { static_assert(!is_pointer::value, @@ -2699,13 +2707,13 @@ private: typedef typename remove_reference::type& _Dp_reference; typedef const typename remove_reference::type& _Dp_const_reference; public: - _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) { static_assert(!is_pointer::value, "unique_ptr constructed with null function pointer deleter"); } - _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) { static_assert(!is_pointer::value, @@ -2955,7 +2963,7 @@ operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {re template inline _LIBCPP_INLINE_VISIBILITY bool -operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) +operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT { return !__x; } @@ -2963,7 +2971,7 @@ operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) template inline _LIBCPP_INLINE_VISIBILITY bool -operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) +operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT { return !__x; } @@ -2971,7 +2979,7 @@ operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) template inline _LIBCPP_INLINE_VISIBILITY bool -operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) +operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT { return static_cast(__x); } @@ -2979,7 +2987,7 @@ operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) template inline _LIBCPP_INLINE_VISIBILITY bool -operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) +operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT { return static_cast(__x); } @@ -3736,8 +3744,8 @@ private: struct __nat {int __for_bool_;}; public: - shared_ptr() _NOEXCEPT; - shared_ptr(nullptr_t) _NOEXCEPT; + _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; + _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; template inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr() _NOEXCEPT : __ptr_(0), __cntrl_(0) @@ -4005,6 +4014,7 @@ shared_ptr<_Tp>::shared_ptr() _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(0), __cntrl_(0) @@ -4895,7 +4905,7 @@ private: __shared_weak_count* __cntrl_; public: - weak_ptr() _NOEXCEPT; + _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; template weak_ptr(shared_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; @@ -4967,6 +4977,7 @@ public: template inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR weak_ptr<_Tp>::weak_ptr() _NOEXCEPT : __ptr_(0), __cntrl_(0) @@ -5197,7 +5208,7 @@ class _LIBCPP_VISIBLE enable_shared_from_this { mutable weak_ptr<_Tp> __weak_this_; protected: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR enable_shared_from_this() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} diff --git a/include/tuple b/include/tuple index 9e05759a..d2bc21f8 100644 --- a/include/tuple +++ b/include/tuple @@ -130,7 +130,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_VISIBLE allocator_arg_t { }; +#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) extern const allocator_arg_t allocator_arg; +#else +constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#endif // uses_allocator diff --git a/src/memory.cpp b/src/memory.cpp index a892e75c..e298c723 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_MEMORY #include "memory" _LIBCPP_BEGIN_NAMESPACE_STD