Re: [patch] Use delegating constructors in std::shared_ptr

2014-04-15 Thread Jonathan Wakely

On 15/04/14 21:51 +0200, Václav Zeman wrote:

On 04/15/2014 08:29 PM, Jonathan Wakely wrote:

A minor simplification that removes a longstanding TODO note.

Tested x86_64-linux, committed to trunk.



diff --git a/libstdc++-v3/include/bits/shared_ptr.h 
b/libstdc++-v3/include/bits/shared_ptr.h
index 081d3bd..104c869 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -262,8 +262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @param  __p  A null pointer constant.
*  @post   use_count() == 0 && get() == nullptr
*/
-  constexpr shared_ptr(nullptr_t __p) noexcept
-  : __shared_ptr<_Tp>(__p) { }
+  constexpr shared_ptr(nullptr_t __p) noexcept : shared_ptr() { }

   ^^^

Will this not cause unused parameter warning or some such?


Not usually, because it's in a system header, but I'll commit the
attached patch when it finishes testing anyway. Thanks.


commit 1048a84b2f4a8626fe32cbfca5fd65701a71bd58
Author: Jonathan Wakely 
Date:   Tue Apr 15 20:56:59 2014 +0100

* include/bits/shared_ptr.h (shared_ptr::shared_ptr(nullptr_t)):
Remove name of unused parameter.

diff --git a/libstdc++-v3/include/bits/shared_ptr.h 
b/libstdc++-v3/include/bits/shared_ptr.h
index 104c869..290a0c9 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -262,7 +262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @param  __p  A null pointer constant.
*  @post   use_count() == 0 && get() == nullptr
*/
-  constexpr shared_ptr(nullptr_t __p) noexcept : shared_ptr() { }
+  constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { }
 
   shared_ptr& operator=(const shared_ptr&) noexcept = default;
 


[patch] Use delegating constructors in std::shared_ptr

2014-04-15 Thread Jonathan Wakely

A minor simplification that removes a longstanding TODO note.

Tested x86_64-linux, committed to trunk.
commit 7769b63f43899b901bba08e5b2b3a6806e2195f2
Author: Jonathan Wakely 
Date:   Tue Apr 15 19:00:47 2014 +0100

* include/bits/shared_ptr.h (shared_ptr::shared_ptr(nullptr_t)): Use
delegating constructor.
* include/bits/shared_ptr_base.h
(__shared_ptr::__shared_ptr(nullptr_t)): Likewise

diff --git a/libstdc++-v3/include/bits/shared_ptr.h 
b/libstdc++-v3/include/bits/shared_ptr.h
index 081d3bd..104c869 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -262,8 +262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @param  __p  A null pointer constant.
*  @post   use_count() == 0 && get() == nullptr
*/
-  constexpr shared_ptr(nullptr_t __p) noexcept
-  : __shared_ptr<_Tp>(__p) { }
+  constexpr shared_ptr(nullptr_t __p) noexcept : shared_ptr() { }
 
   shared_ptr& operator=(const shared_ptr&) noexcept = default;
 
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h 
b/libstdc++-v3/include/bits/shared_ptr_base.h
index 536df01..57398af 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -963,10 +963,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__shared_ptr(std::auto_ptr<_Tp1>&& __r);
 #endif
 
-  /* TODO: use delegating constructor */
-  constexpr __shared_ptr(nullptr_t) noexcept
-  : _M_ptr(0), _M_refcount()
-  { }
+  constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
 
   template
__shared_ptr&