summaryrefslogtreecommitdiff
path: root/include/memory
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-06-02 00:15:35 +0000
committerEric Fiselier <eric@efcs.ca>2016-06-02 00:15:35 +0000
commit18e1ea69ae04be16072d0c781bc8b7c342c2a7ff (patch)
tree54b5c5c9fea2dfc35b9d99b69503a3f5b88c6812 /include/memory
parent84acb1ec3f7d5e0f37d7176697c2fa876c413407 (diff)
Implement P0033R1 - Re-enabling shared_from_this
Summary: See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0033r1.html Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19254 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/memory')
-rw-r--r--include/memory12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/memory b/include/memory
index 7627248a4..014635234 100644
--- a/include/memory
+++ b/include/memory
@@ -4120,7 +4120,7 @@ private:
void
__enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
{
- if (__e)
+ if (__e && __e->__weak_this_.expired())
{
__e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e));
__e->__weak_this_.__cntrl_ = __cntrl_;
@@ -5432,6 +5432,16 @@ public:
shared_ptr<_Tp const> shared_from_this() const
{return shared_ptr<const _Tp>(__weak_this_);}
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr<_Tp> weak_from_this() _NOEXCEPT
+ { return __weak_this_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT
+ { return __weak_this_; }
+#endif // _LIBCPP_STD_VER > 14
+
template <class _Up> friend class shared_ptr;
};