[cfe-commits] [libcxx] r155918 - in /libcxx/trunk/include: memory type_traits

Howard Hinnant hhinnant at apple.com
Tue May 1 08:37:54 PDT 2012


Author: hhinnant
Date: Tue May  1 10:37:54 2012
New Revision: 155918

URL: http://llvm.org/viewvc/llvm-project?rev=155918&view=rev
Log:
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.

Modified:
    libcxx/trunk/include/memory
    libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=155918&r1=155917&r2=155918&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue May  1 10:37:54 2012
@@ -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

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=155918&r1=155917&r2=155918&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue May  1 10:37:54 2012
@@ -1298,24 +1298,8 @@
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template <class _Tp>
-class __rv
-{
-    typedef typename remove_reference<_Tp>::type _Trr;
-    _Trr& t_;
-public:
-    _LIBCPP_INLINE_VISIBILITY
-    _Trr* operator->() {return &t_;}
-    _LIBCPP_INLINE_VISIBILITY
-    explicit __rv(_Trr& __t) : t_(__t) {}
-};
-
-template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_convertible<_Tp, __rv<_Tp> >::value,
-    _Tp&
->::type
+_Tp&
 move(_Tp& __t)
 {
     return __t;
@@ -1323,11 +1307,7 @@
 
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-    !is_convertible<_Tp, __rv<_Tp> >::value,
-    const _Tp&
->::type
+const _Tp&
 move(const _Tp& __t)
 {
     return __t;
@@ -1335,63 +1315,24 @@
 
 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)
+_Tp&
+forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
 {
     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)
+template <class _Tp>
+class __rv
 {
-    return _Tp(__rv<_Tp>(__t));
-}
+    typedef typename remove_reference<_Tp>::type _Trr;
+    _Trr& t_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _Trr* operator->() {return &t_;}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __rv(_Trr& __t) : t_(__t) {}
+};
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 





More information about the cfe-commits mailing list