[patch] Use delegating constructors in std::shared_ptr
Jonathan Wakely
jwakely@redhat.com
Tue Apr 15 18:29:00 GMT 2014
A minor simplification that removes a longstanding TODO note.
Tested x86_64-linux, committed to trunk.
-------------- next part --------------
commit 7769b63f43899b901bba08e5b2b3a6806e2195f2
Author: Jonathan Wakely <accu@kayari.org>
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<typename _Tp1>
__shared_ptr&
More information about the Libstdc++
mailing list