diff options
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/shared_ptr.h | 22 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/shared_ptr_base.h | 22 |
2 files changed, 28 insertions, 16 deletions
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index 2413b1b8e10..26a0ad3d7b7 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -582,19 +582,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept { _M_weak_this._M_assign(__p, __n); } - template<typename _Tp1> + template<typename _Tp1, typename _Tp2> friend void - __enable_shared_from_this_helper(const __shared_count<>& __pn, - const enable_shared_from_this* __pe, - const _Tp1* __px) noexcept - { - if (__pe != nullptr) - __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); - } + __enable_shared_from_this_helper(const __shared_count<>&, + const enable_shared_from_this<_Tp1>*, + const _Tp2*) noexcept; mutable weak_ptr<_Tp> _M_weak_this; }; + template<typename _Tp1, typename _Tp2> + inline void + __enable_shared_from_this_helper(const __shared_count<>& __pn, + const enable_shared_from_this<_Tp1>* + __pe, const _Tp2* __px) noexcept + { + if (__pe != nullptr) + __pe->_M_weak_assign(const_cast<_Tp2*>(__px), __pn); + } + /** * @brief Create an object that is owned by a shared_ptr. * @param __a An allocator. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 1a96b4cd36d..f4f98e6fdc4 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1546,19 +1546,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept { _M_weak_this._M_assign(__p, __n); } - template<typename _Tp1> + template<_Lock_policy _Lp1, typename _Tp1, typename _Tp2> friend void - __enable_shared_from_this_helper(const __shared_count<_Lp>& __pn, - const __enable_shared_from_this* __pe, - const _Tp1* __px) noexcept - { - if (__pe != nullptr) - __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); - } + __enable_shared_from_this_helper(const __shared_count<_Lp1>&, + const __enable_shared_from_this<_Tp1, + _Lp1>*, const _Tp2*) noexcept; mutable __weak_ptr<_Tp, _Lp> _M_weak_this; }; + template<_Lock_policy _Lp1, typename _Tp1, typename _Tp2> + inline void + __enable_shared_from_this_helper(const __shared_count<_Lp1>& __pn, + const __enable_shared_from_this<_Tp1, + _Lp1>* __pe, + const _Tp2* __px) noexcept + { + if (__pe != nullptr) + __pe->_M_weak_assign(const_cast<_Tp2*>(__px), __pn); + } template<typename _Tp, _Lock_policy _Lp, typename _Alloc, typename... _Args> inline __shared_ptr<_Tp, _Lp> |