This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[PATCH] [4.6] shared_ptr needs explicit copy constructor


When compiling with a compiler that is conformant to the c++11 spec for PR
c++/50500, std::shared_ptr must have an explicitly defined copy constructor.

Backported from revision 180159. The rest of the revision includes new
functionality, so only this part should be applied to 4.6. This has been
tested on an x86_64 host with clang 3.0 as the C++ compiler.

PR c++/50500
* Explicitly define default copy constructor for std::shared_ptr
--- a/src/libstdc++-v3/include/bits/shared_ptr.h	(revision 180158)
+++ b/src/libstdc++-v3/include/bits/shared_ptr.h	(revision 180159)
@@ -211,6 +211,7 @@
        *  @param  __r  A %shared_ptr.
        *  @post   get() == __r.get() && use_count() == __r.use_count()
        */
+      shared_ptr(const shared_ptr&) = default; // never throws
       template<typename _Tp1, typename = typename
 	       std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
 	shared_ptr(const shared_ptr<_Tp1>& __r)
@@ -264,6 +265,7 @@
       constexpr shared_ptr(nullptr_t __p)
       : __shared_ptr<_Tp>(__p) { }
 
+      shared_ptr& operator=(const shared_ptr&) = default;
       template<typename _Tp1>
 	shared_ptr&
 	operator=(const shared_ptr<_Tp1>& __r) // never throws
--- a/src/libstdc++-v3/include/bits/shared_ptr_base.h	2011/03/22 15:15:03	171293
+++ b/src/libstdc++-v3/include/bits/shared_ptr_base.h	2011/05/18 22:59:17	173882
@@ -799,7 +801,9 @@
 	: _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws
 	{ }
 
-      //  generated copy constructor, assignment, destructor are fine.
+      __shared_ptr(const __shared_ptr&) = default; // never throws
+      __shared_ptr& operator=(const __shared_ptr&) = default; // never throws
+      ~__shared_ptr() = default;
 
       template<typename _Tp1, typename = typename
 	       std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
@@ -1216,7 +1220,9 @@
       : _M_ptr(0), _M_refcount() // never throws
       { }
 
-      // Generated copy constructor, assignment, destructor are fine.
+      __weak_ptr(const __weak_ptr&) = default; // never throws
+      __weak_ptr& operator=(const __weak_ptr&) = default; // never throws
+      ~__weak_ptr() = default;
 
       // The "obvious" converting constructor implementation:
       //


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