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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@155918 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/memory b/include/memory
index aa24f96..e30a6fd 100644
--- a/include/memory
+++ b/include/memory
@@ -1685,39 +1685,21 @@
::new((void*)__p) _Tp();
}
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
template <class _A0>
_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 <class _A0>
_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 <class _A0>
- _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 <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
@@ -1793,39 +1775,21 @@
::new((void*)__p) _Tp();
}
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
template <class _A0>
_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 <class _A0>
_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 <class _A0>
- _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 <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
@@ -3086,6 +3050,18 @@
return !(nullptr < __x);
}
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+unique_ptr<_Tp, _Dp>
+move(unique_ptr<_Tp, _Dp>& __t)
+{
+ return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t));
+}
+
+#endif
+
template <class _Tp> struct hash;
// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
diff --git a/include/type_traits b/include/type_traits
index f68ed6d..a54e252 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -1298,6 +1298,31 @@
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp&
+move(_Tp& __t)
+{
+ return __t;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp&
+move(const _Tp& __t)
+{
+ return __t;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp&
+forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
+{
+ return __t;
+}
+
+
+template <class _Tp>
class __rv
{
typedef typename remove_reference<_Tp>::type _Trr;
@@ -1309,90 +1334,6 @@
explicit __rv(_Trr& __t) : t_(__t) {}
};
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_convertible<_Tp, __rv<_Tp> >::value,
- _Tp&
->::type
-move(_Tp& __t)
-{
- return __t;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_convertible<_Tp, __rv<_Tp> >::value,
- const _Tp&
->::type
-move(const _Tp& __t)
-{
- return __t;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_convertible<_Tp, __rv<_Tp> >::value,
- _Tp
->::type
-move(_Tp& __t)
-{
- return _Tp(__rv<_Tp>(__t));
-}
-
-template <class _Tp, class _Up>
-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 <class _Tp, class _Up>
-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 <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_convertible<_Tp, __rv<_Tp> >::value,
- _Tp
->::type
-forward(_Up& __t)
-{
- return _Tp(__rv<_Tp>(__t));
-}
-
-template <class _Tp, class _Up>
-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 <class _Tp>