[libcxx-commits] [PATCH] D80881: [NFC] [libcxx] Remove shared_ptr's no-rvalue unique_ptr converting constructor.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 30 15:22:26 PDT 2020


zoecarver created this revision.
zoecarver added a reviewer: ldionne.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
zoecarver added a comment.

This passes all memory tests in C++03, C++11, and C++2a mode.


All compilers supported by libc++ have rvalues in C++03 mode so, there is no need for this non-rvalue overload.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80881

Files:
  libcxx/include/memory
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp


Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -94,16 +94,9 @@
         }
         catch (...)
         {
-#if TEST_STD_VER >= 11
             assert(A::count == 1);
             assert(B::count == 1);
             assert(ptr.get() == raw_ptr);
-#else
-            (void) raw_ptr; // silence 'unused variable' warning
-            assert(A::count == 0);
-            assert(B::count == 0);
-            assert(ptr.get() == 0);
-#endif // TEST_STD_VER >= 11
         }
     }
 #endif
Index: libcxx/include/memory
===================================================================
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3597,7 +3597,6 @@
                    typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
 #endif
 #endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     template <class _Yp, class _Dp>
         shared_ptr(unique_ptr<_Yp, _Dp>&&,
                    typename enable_if
@@ -3616,26 +3615,6 @@
                        is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
                        __nat
                    >::type = __nat());
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    template <class _Yp, class _Dp>
-        shared_ptr(unique_ptr<_Yp, _Dp>,
-                   typename enable_if
-                   <
-                       !is_lvalue_reference<_Dp>::value &&
-                       !is_array<_Yp>::value &&
-                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
-                       __nat
-                   >::type = __nat());
-    template <class _Yp, class _Dp>
-        shared_ptr(unique_ptr<_Yp, _Dp>,
-                   typename enable_if
-                   <
-                       is_lvalue_reference<_Dp>::value &&
-                       !is_array<_Yp>::value &&
-                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
-                       __nat
-                   >::type = __nat());
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
     ~shared_ptr();
 
@@ -4060,11 +4039,7 @@
 
 template<class _Tp>
 template <class _Yp, class _Dp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
-#else
-shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
-#endif
                             typename enable_if
                             <
                                 !is_lvalue_reference<_Dp>::value &&
@@ -4090,11 +4065,7 @@
 
 template<class _Tp>
 template <class _Yp, class _Dp>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
-#else
-shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
-#endif
                             typename enable_if
                             <
                                 is_lvalue_reference<_Dp>::value &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80881.267481.patch
Type: text/x-patch
Size: 3264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200530/4a61fc77/attachment-0001.bin>


More information about the libcxx-commits mailing list