summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-07-07 20:56:04 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-07-07 20:56:04 +0000
commitc0937e8add9e010e80f3e631195019922b261ae7 (patch)
treee3dccd12ad14eae634846389dbdcbf3f3391cac3
parentbfa7990b5a5cc72921caa5d3231b3865b09164f3 (diff)
downloadbcm5719-llvm-c0937e8add9e010e80f3e631195019922b261ae7.tar.gz
bcm5719-llvm-c0937e8add9e010e80f3e631195019922b261ae7.zip
Appy constexpr to <memory>. Picked up a few missing noexcepts as well.
llvm-svn: 159902
-rw-r--r--libcxx/include/memory39
-rw-r--r--libcxx/include/tuple4
-rw-r--r--libcxx/src/memory.cpp1
3 files changed, 30 insertions, 14 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 0f3ccec50af..b181bc9da0b 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -2467,7 +2467,11 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true>
template <class _Tp>
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 <class _Up>
_LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&,
typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
@@ -2482,7 +2486,11 @@ template <class _Tp>
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 <class _Up>
_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<deleter_type>::type& _Dp_reference;
typedef const typename remove_reference<deleter_type>::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<deleter_type>::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<deleter_type>::value,
@@ -2699,13 +2707,13 @@ private:
typedef typename remove_reference<deleter_type>::type& _Dp_reference;
typedef const typename remove_reference<deleter_type>::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<deleter_type>::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<deleter_type>::value,
@@ -2955,7 +2963,7 @@ operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {re
template <class _T1, class _D1>
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 <class _T1, class _D1>
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 <class _T1, class _D1>
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<bool>(__x);
}
@@ -2979,7 +2987,7 @@ operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
template <class _T1, class _D1>
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<bool>(__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<class _Yp,
class = typename enable_if
<
@@ -3997,6 +4005,7 @@ private:
template<class _Tp>
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<class _Tp>
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<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r,
typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
_NOEXCEPT;
@@ -4967,6 +4977,7 @@ public:
template<class _Tp>
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/libcxx/include/tuple b/libcxx/include/tuple
index 9e05759a30a..d2bc21f80ca 100644
--- a/libcxx/include/tuple
+++ b/libcxx/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/libcxx/src/memory.cpp b/libcxx/src/memory.cpp
index a892e75c86d..e298c723c1e 100644
--- a/libcxx/src/memory.cpp
+++ b/libcxx/src/memory.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_BUILDING_MEMORY
#include "memory"
_LIBCPP_BEGIN_NAMESPACE_STD
OpenPOWER on IntegriCloud