diff mbox

[4.6] shared_ptr needs explicit copy constructor

Message ID 4F032F4E.2020309@canonical.com
State New
Headers show

Commit Message

Chase Douglas Jan. 3, 2012, 4:39 p.m. UTC
Fixing a typo when Cc'ing Matthias Klose.

---

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
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:
       //
diff mbox

Patch

--- 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