This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++0x] remove swap for rvalues - redux


I missed std::shared_ptr from the patch at
http://gcc.gnu.org/ml/libstdc++/2009-05/msg00114.html

The attached patch fixes that, and adds some missing 'test' variables
to the testsuite.

        * include/bits/shared_ptr.h: Do not swap rvalues.
        * testsuite/20_util/owner_less/cmp.cc: Add missing test variables.
        * testsuite/20_util/shared_ptr/comparison/cmp.cc: Likewise.
        * testsuite/20_util/shared_ptr/comparison/less.cc: Likewise.
        * testsuite/20_util/weak_ptr/observers/owner_before.cc: Likewise.
        * testsuite/20_util/tuple/swap.cc: Likewise.

tested linux/x86_64, ok for trunk?

Jonathan
Index: include/bits/shared_ptr.h
===================================================================
--- include/bits/shared_ptr.h	(revision 148809)
+++ include/bits/shared_ptr.h	(working copy)
@@ -828,7 +828,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       { return _M_refcount._M_get_use_count(); }
 
       void
-      swap(__shared_ptr<_Tp, _Lp>&& __other) // never throws
+      swap(__shared_ptr<_Tp, _Lp>& __other) // never throws
       {
 	std::swap(_M_ptr, __other._M_ptr);
 	_M_refcount._M_swap(__other._M_refcount);
@@ -938,16 +938,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
     { __a.swap(__b); }
 
-  template<typename _Tp, _Lock_policy _Lp>
-    inline void
-    swap(__shared_ptr<_Tp, _Lp>&& __a, __shared_ptr<_Tp, _Lp>& __b)
-    { __a.swap(__b); }
-
-  template<typename _Tp, _Lock_policy _Lp>
-    inline void
-    swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>&& __b)
-    { __a.swap(__b); }
-
   // 2.2.3.9 shared_ptr casts
   /** @warning The seemingly equivalent
    *           <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code>
@@ -1367,16 +1357,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
     { __a.swap(__b); }
 
-  template<typename _Tp>
-    inline void
-    swap(shared_ptr<_Tp>&& __a, shared_ptr<_Tp>& __b)
-    { __a.swap(__b); }
-
-  template<typename _Tp>
-    inline void
-    swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>&& __b)
-    { __a.swap(__b); }
-
   // 20.8.13.2.10 shared_ptr casts.
   template<typename _Tp, typename _Tp1>
     inline shared_ptr<_Tp>
Index: testsuite/20_util/owner_less/cmp.cc
===================================================================
--- testsuite/20_util/owner_less/cmp.cc	(revision 148809)
+++ testsuite/20_util/owner_less/cmp.cc	(working copy)
@@ -32,16 +32,18 @@ struct B { A a[2]; };
 int
 test01()
 {
-    // test empty shared_ptrs compare equivalent
-    std::owner_less<std::shared_ptr<A>> less;
-    std::owner_less<std::weak_ptr<A>> wless;
-    std::shared_ptr<A> p1;
-    std::shared_ptr<A> p2;
-    VERIFY( !less(p1, p2) && !less(p2, p1) );
-    std::weak_ptr<A> p3;
-    VERIFY( !less(p1, p3) && !less(p3, p1) );
-    VERIFY( !wless(p1, p3) && !wless(p3, p1) );
-    return 0;
+  bool test __attribute__((unused)) = true;
+
+  // test empty shared_ptrs compare equivalent
+  std::owner_less<std::shared_ptr<A>> less;
+  std::owner_less<std::weak_ptr<A>> wless;
+  std::shared_ptr<A> p1;
+  std::shared_ptr<A> p2;
+  VERIFY( !less(p1, p2) && !less(p2, p1) );
+  std::weak_ptr<A> p3;
+  VERIFY( !less(p1, p3) && !less(p3, p1) );
+  VERIFY( !wless(p1, p3) && !wless(p3, p1) );
+  return 0;
 }
 
 
@@ -49,6 +51,8 @@ test01()
 int
 test02()
 {
+  bool test __attribute__((unused)) = true;
+
   std::owner_less<std::shared_ptr<A>> less;
   std::owner_less<std::weak_ptr<A>> wless;
 
@@ -80,6 +84,8 @@ test02()
 int
 test03()
 {
+  bool test __attribute__((unused)) = true;
+
   std::owner_less<std::shared_ptr<A>> less;
   std::owner_less<std::weak_ptr<A>> wless;
 
@@ -102,6 +108,8 @@ test03()
 int
 test04()
 {
+  bool test __attribute__((unused)) = true;
+
   std::owner_less<std::shared_ptr<A>> less;
 
   std::shared_ptr<A> a[3];
Index: testsuite/20_util/shared_ptr/comparison/cmp.cc
===================================================================
--- testsuite/20_util/shared_ptr/comparison/cmp.cc	(revision 148809)
+++ testsuite/20_util/shared_ptr/comparison/cmp.cc	(working copy)
@@ -36,13 +36,15 @@ struct B : A
 int
 test01()
 {
-    // test empty shared_ptrs compare equivalent
-    std::shared_ptr<A> p1;
-    std::shared_ptr<B> p2;
-    VERIFY( p1 == p2 );
-    VERIFY( !(p1 != p2) );
-    VERIFY( !(p1 < p2) && !(p2 < p1) );
-    return 0;
+  bool test __attribute__((unused)) = true;
+
+  // test empty shared_ptrs compare equivalent
+  std::shared_ptr<A> p1;
+  std::shared_ptr<B> p2;
+  VERIFY( p1 == p2 );
+  VERIFY( !(p1 != p2) );
+  VERIFY( !(p1 < p2) && !(p2 < p1) );
+  return 0;
 }
 
 
@@ -50,6 +52,8 @@ test01()
 int
 test02()
 {
+  bool test __attribute__((unused)) = true;
+
   std::shared_ptr<A> A_default;
 
   std::shared_ptr<A> A_from_A(new A);
@@ -78,6 +82,8 @@ test02()
 int
 test03()
 {
+  bool test __attribute__((unused)) = true;
+
   std::shared_ptr<A> p1;
 
   // check other operators are defined
Index: testsuite/20_util/shared_ptr/comparison/less.cc
===================================================================
--- testsuite/20_util/shared_ptr/comparison/less.cc	(revision 148809)
+++ testsuite/20_util/shared_ptr/comparison/less.cc	(working copy)
@@ -41,6 +41,8 @@ namespace std
 int
 test01()
 {
+  bool test __attribute__((unused)) = true;
+
   std::less<std::shared_ptr<A>> less;
   // test empty shared_ptrs compare equivalent
   std::shared_ptr<A> p1;
@@ -55,6 +57,8 @@ test01()
 int
 test02()
 {
+  bool test __attribute__((unused)) = true;
+
   std::less<std::shared_ptr<A>> less;
 
   std::shared_ptr<A> empty;
@@ -77,6 +81,8 @@ test02()
 int
 test03()
 {
+  bool test __attribute__((unused)) = true;
+
   std::less<std::shared_ptr<A>> less;
 
   A a;
Index: testsuite/20_util/weak_ptr/observers/owner_before.cc
===================================================================
--- testsuite/20_util/weak_ptr/observers/owner_before.cc	(revision 148809)
+++ testsuite/20_util/weak_ptr/observers/owner_before.cc	(working copy)
@@ -30,6 +30,8 @@ struct B { };
 int
 test01()
 {
+  bool test __attribute__((unused)) = true;
+
   // test empty weak_ptrs compare equivalent
   std::weak_ptr<A> p1;
   std::weak_ptr<B> p2;
@@ -45,6 +47,8 @@ test01()
 int
 test02()
 {
+  bool test __attribute__((unused)) = true;
+
   std::shared_ptr<A> a0;
   std::weak_ptr<A> w0(a0);
 
Index: testsuite/20_util/tuple/swap.cc
===================================================================
--- testsuite/20_util/tuple/swap.cc	(revision 148809)
+++ testsuite/20_util/tuple/swap.cc	(working copy)
@@ -56,6 +56,8 @@ make_move_only (int i)
 
 void test01()
 {
+  bool test __attribute__((unused)) = true;
+
   std::tuple<> t1, t2;
   std::swap(t1, t2);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]