From bff1bfc6be0615ba3036a861fd27b75c96e3297c Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 1 May 2012 15:37:54 +0000 Subject: [PATCH] Greatly scale back ambitions of emulating move semantics in C++03 mode. It was causing more problems than it solved. This fixes http://llvm.org/bugs/show_bug.cgi?id=12704. llvm-svn: 155918 --- libcxx/include/memory | 60 ++++++-------------- libcxx/include/type_traits | 109 +++++++++---------------------------- 2 files changed, 43 insertions(+), 126 deletions(-) diff --git a/libcxx/include/memory b/libcxx/include/memory index aa24f960aecf..e30a6fd7c5b4 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1685,39 +1685,21 @@ public: ::new((void*)__p) _Tp(); } # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + template _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - !is_convertible<_A0, __rv<_A0> >::value, - void - >::type + void construct(pointer __p, _A0& __a0) { ::new((void*)__p) _Tp(__a0); } template _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - !is_convertible<_A0, __rv<_A0> >::value, - void - >::type + void construct(pointer __p, const _A0& __a0) { ::new((void*)__p) _Tp(__a0); } - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - is_convertible<_A0, __rv<_A0> >::value, - void - >::type - construct(pointer __p, _A0 __a0) - { - ::new((void*)__p) _Tp(_VSTD::move(__a0)); - } # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template _LIBCPP_INLINE_VISIBILITY @@ -1793,39 +1775,21 @@ public: ::new((void*)__p) _Tp(); } # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + template _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - !is_convertible<_A0, __rv<_A0> >::value, - void - >::type + void construct(pointer __p, _A0& __a0) { ::new((void*)__p) _Tp(__a0); } template _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - !is_convertible<_A0, __rv<_A0> >::value, - void - >::type + void construct(pointer __p, const _A0& __a0) { ::new((void*)__p) _Tp(__a0); } - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - is_convertible<_A0, __rv<_A0> >::value, - void - >::type - construct(pointer __p, _A0 __a0) - { - ::new((void*)__p) _Tp(_VSTD::move(__a0)); - } # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template _LIBCPP_INLINE_VISIBILITY @@ -3086,6 +3050,18 @@ operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) return !(nullptr < __x); } +#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +inline _LIBCPP_INLINE_VISIBILITY +unique_ptr<_Tp, _Dp> +move(unique_ptr<_Tp, _Dp>& __t) +{ + return unique_ptr<_Tp, _Dp>(__rv >(__t)); +} + +#endif + template struct hash; // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index f68ed6dd29a1..a54e25204eeb 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1297,6 +1297,31 @@ forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp& +move(_Tp& __t) +{ + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +const _Tp& +move(const _Tp& __t) +{ + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp& +forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT +{ + return __t; +} + + template class __rv { @@ -1309,90 +1334,6 @@ public: explicit __rv(_Trr& __t) : t_(__t) {} }; -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_convertible<_Tp, __rv<_Tp> >::value, - _Tp& ->::type -move(_Tp& __t) -{ - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_convertible<_Tp, __rv<_Tp> >::value, - const _Tp& ->::type -move(const _Tp& __t) -{ - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_convertible<_Tp, __rv<_Tp> >::value, - _Tp ->::type -move(_Tp& __t) -{ - return _Tp(__rv<_Tp>(__t)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_convertible<_Tp, __rv<_Tp> >::value, - typename add_lvalue_reference<_Tp>::type ->::type -forward(_Up& __t) -{ - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_convertible<_Tp, __rv<_Tp> >::value, - typename add_lvalue_reference<_Tp>::type ->::type -forward(const _Up& __t) -{ - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_convertible<_Tp, __rv<_Tp> >::value, - _Tp ->::type -forward(_Up& __t) -{ - return _Tp(__rv<_Tp>(__t)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_convertible<_Tp, __rv<_Tp> >::value, - _Tp ->::type -forward(const _Up& __t) -{ - return _Tp(__rv<_Tp>(__t)); -} - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template