summaryrefslogtreecommitdiffstats
path: root/libcxx/include/memory
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-06-21 15:20:55 +0000
committerEric Fiselier <eric@efcs.ca>2019-06-21 15:20:55 +0000
commit000f25a37e76317aa78b0f6dd9283ba41af94591 (patch)
tree988a2d163afe5459926808aaa05139cc86ec7e61 /libcxx/include/memory
parentddb9093684062b6552b338ff754c674e79a55826 (diff)
downloadbcm5719-llvm-000f25a37e76317aa78b0f6dd9283ba41af94591.tar.gz
bcm5719-llvm-000f25a37e76317aa78b0f6dd9283ba41af94591.zip
Make move and forward work in C++03.
These functions are key to allowing the use of rvalues and variadics in C++03 mode. Everything works the same as in C++11, except for one tangentially related case: struct T { T(T &&) = default; }; In C++11, T has a deleted copy constructor. But in C++03 Clang gives it both a move and a copy constructor. This seems reasonable enough given the extensions it's using. The other changes in this patch were the minimal set required to keep the tests passing after the move/forward change. Most notably the removal of the `__rv<unique_ptr>` hack that was present in an attempt to make unique_ptr move only without language support. llvm-svn: 364063
Diffstat (limited to 'libcxx/include/memory')
-rw-r--r--libcxx/include/memory42
1 files changed, 10 insertions, 32 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory
index b8a2706570f..cabf3d7cd74 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -2561,14 +2561,9 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- operator __rv<unique_ptr>() {
- return __rv<unique_ptr>(*this);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(__rv<unique_ptr> __u)
- : __ptr_(__u->release(),
- _VSTD::forward<deleter_type>(__u->get_deleter())) {}
+ unique_ptr(unique_ptr&& __u)
+ : __ptr_(__u.release(),
+ _VSTD::forward<deleter_type>(__u.get_deleter())) {}
template <class _Up, class _Ep>
_LIBCPP_INLINE_VISIBILITY
@@ -2586,7 +2581,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
unique_ptr(pointer __p, deleter_type __d)
- : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {}
+ : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {}
#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
@@ -2863,19 +2858,14 @@ public:
: __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {}
_LIBCPP_INLINE_VISIBILITY
- operator __rv<unique_ptr>() {
- return __rv<unique_ptr>(*this);
- }
+ unique_ptr(unique_ptr&& __u)
+ : __ptr_(__u.release(),
+ _VSTD::forward<deleter_type>(__u.get_deleter())) {}
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(__rv<unique_ptr> __u)
- : __ptr_(__u->release(),
- _VSTD::forward<deleter_type>(__u->get_deleter())) {}
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(__rv<unique_ptr> __u) {
- reset(__u->release());
- __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter());
+ unique_ptr& operator=(unique_ptr&& __u) {
+ reset(__u.release());
+ __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
return *this;
}
@@ -3091,18 +3081,6 @@ operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
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
-
#if _LIBCPP_STD_VER > 11
template<class _Tp>
OpenPOWER on IntegriCloud