From 030d19bd1a0d816ece24d5e7c248d9e60fe0f373 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 16 Apr 2017 02:06:25 +0000 Subject: [PATCH] Cleanup default_delete specializations llvm-svn: 300407 --- libcxx/include/memory | 98 ++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/libcxx/include/memory b/libcxx/include/memory index faf89aa..41c3bda 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2245,75 +2245,63 @@ void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) __x.swap(__y); } -// __same_or_less_cv_qualified - -template ::element_type>::type, - typename remove_cv::element_type>::type - >::value - > -struct __same_or_less_cv_qualified_imp - : is_convertible<_Ptr1, _Ptr2> {}; - -template -struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> - : false_type {}; - -template ::value || - is_same<_Ptr1, _Ptr2>::value || - __has_element_type<_Ptr1>::value> -struct __same_or_less_cv_qualified - : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; - -template -struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false> - : false_type {}; - // default_delete template -struct _LIBCPP_TEMPLATE_VIS default_delete -{ -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; +struct _LIBCPP_TEMPLATE_VIS default_delete { +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY constexpr default_delete() noexcept = default; #else - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY default_delete() {} #endif - template - _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, - typename enable_if::value>::type* = 0) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT - { - static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); - static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); - delete __ptr; - } + template + _LIBCPP_INLINE_VISIBILITY + default_delete(const default_delete<_Up>&, + typename enable_if::value>::type* = + 0) _NOEXCEPT {} + + _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT { + static_assert(sizeof(_Tp) > 0, + "default_delete can not delete incomplete type"); + static_assert(!is_void<_Tp>::value, + "default_delete can not delete incomplete type"); + delete __ptr; + } }; template -struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> -{ +struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> { +private: + template + struct _EnableIfConvertible + : enable_if::value> {}; + public: -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY constexpr default_delete() noexcept = default; #else - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY default_delete() {} #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 {} - template - _LIBCPP_INLINE_VISIBILITY - void operator() (_Up* __ptr, - typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT - { - static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); - static_assert(!is_void<_Tp>::value, "default_delete can not delete void type"); - delete [] __ptr; - } + + template + _LIBCPP_INLINE_VISIBILITY + default_delete(const default_delete<_Up[]>&, + typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {} + + template + _LIBCPP_INLINE_VISIBILITY + typename _EnableIfConvertible<_Up>::type + operator()(_Up* __ptr) const _NOEXCEPT { + static_assert(sizeof(_Tp) > 0, + "default_delete can not delete incomplete type"); + static_assert(!is_void<_Tp>::value, + "default_delete can not delete void type"); + delete[] __ptr; + } }; + #ifndef _LIBCPP_CXX03_LANG template struct __unique_ptr_deleter_sfinae { -- 2.7.4