[cfe-commits] [libcxx] r159902 - in /libcxx/trunk: include/memory include/tuple src/memory.cpp
Howard Hinnant
hhinnant at apple.com
Sat Jul 7 13:56:04 PDT 2012
Author: hhinnant
Date: Sat Jul 7 15:56:04 2012
New Revision: 159902
URL: http://llvm.org/viewvc/llvm-project?rev=159902&view=rev
Log:
Appy constexpr to <memory>. Picked up a few missing noexcepts as well.
Modified:
libcxx/trunk/include/memory
libcxx/trunk/include/tuple
libcxx/trunk/src/memory.cpp
Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=159902&r1=159901&r2=159902&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Sat Jul 7 15:56:04 2012
@@ -2467,7 +2467,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
: __ptr_(0),
__cntrl_(0)
@@ -4005,6 +4014,7 @@
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 @@
__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 @@
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
: __ptr_(0),
__cntrl_(0)
@@ -5197,7 +5208,7 @@
{
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 {}
Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=159902&r1=159901&r2=159902&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sat Jul 7 15:56:04 2012
@@ -130,7 +130,11 @@
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
Modified: libcxx/trunk/src/memory.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=159902&r1=159901&r2=159902&view=diff
==============================================================================
--- libcxx/trunk/src/memory.cpp (original)
+++ libcxx/trunk/src/memory.cpp Sat Jul 7 15:56:04 2012
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_BUILDING_MEMORY
#include "memory"
_LIBCPP_BEGIN_NAMESPACE_STD
More information about the cfe-commits
mailing list