1 // <tr1/boost_shared_ptr.h> -*- C++ -*-
3 // Copyright (C) 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
34 // Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes.
35 // Copyright (C) 2001, 2002, 2003 Peter Dimov
38 // Copyright (C) 2001, 2002, 2003 Peter Dimov
40 // enable_shared_from_this.hpp
41 // Copyright (C) 2002 Peter Dimov
43 // Distributed under the Boost Software License, Version 1.0. (See
44 // accompanying file LICENSE_1_0.txt or copy at
45 // http://www.boost.org/LICENSE_1_0.txt)
47 // GCC Note: based on version 1.32.0 of the Boost library.
49 /** @file boost_memory.h
50 * This is an internal header file, included by other library headers.
51 * You should not attempt to use it directly.
54 #ifndef _BOOST_SHARED_PTR_H
55 #define _BOOST_SHARED_PTR_H 1
60 _GLIBCXX_BEGIN_NAMESPACE(tr1
)
62 class bad_weak_ptr
: public std::exception
68 { return "tr1::bad_weak_ptr"; }
71 // Helper for exception objects in <tr1/memory>
72 // TODO this should be defined in a different file.
74 __throw_bad_weak_ptr()
84 template<typename _Tp
>
87 typedef void result_type
;
88 typedef _Tp
* argument_type
;
91 operator()(_Tp
* p
) const
96 class _Sp_counted_base
101 : _M_use_count(1), _M_weak_count(1)
103 // For the case of __GTHREAD_MUTEX_INIT we haven't initialised
104 // the mutex yet, so do it now.
105 #if defined(__GTHREADS) && defined(__GTHREAD_MUTEX_INIT)
106 __gthread_mutex_t __tmp
= __GTHREAD_MUTEX_INIT
;
112 ~_Sp_counted_base() // nothrow
115 // dispose() is called when _M_use_count drops to zero, to release
116 // the resources managed by *this.
118 dispose() = 0; // nothrow
120 // destroy() is called when _M_weak_count drops to zero.
128 get_deleter(const std::type_info
&) = 0;
133 __gnu_cxx::__atomic_add(&_M_use_count
, 1);
139 __gnu_cxx::lock
lock(_M_mutex
);
140 if (__gnu_cxx::__exchange_and_add(&_M_use_count
, 1) == 0)
143 __throw_bad_weak_ptr();
150 if (__gnu_cxx::__exchange_and_add(&_M_use_count
, -1) == 1)
154 _GLIBCXX_READ_MEM_BARRIER
;
155 _GLIBCXX_WRITE_MEM_BARRIER
;
157 if (__gnu_cxx::__exchange_and_add(&_M_weak_count
, -1) == 1)
163 weak_add_ref() // nothrow
165 __gnu_cxx::__atomic_add(&_M_weak_count
, 1);
169 weak_release() // nothrow
171 if (__gnu_cxx::__exchange_and_add(&_M_weak_count
, -1) == 1)
174 _GLIBCXX_READ_MEM_BARRIER
;
175 _GLIBCXX_WRITE_MEM_BARRIER
;
182 use_count() const // nothrow
184 return _M_use_count
; // XXX is this MT safe?
189 _Sp_counted_base(_Sp_counted_base
const&);
190 _Sp_counted_base
& operator=(_Sp_counted_base
const&);
192 _Atomic_word _M_use_count
; // #shared
193 _Atomic_word _M_weak_count
; // #weak + (#shared != 0)
194 __gnu_cxx::mutex_type _M_mutex
;
197 template<typename _Ptr
, typename _Deleter
>
198 class _Sp_counted_base_impl
199 : public _Sp_counted_base
205 * @pre d(p) must not throw.
207 _Sp_counted_base_impl(_Ptr __p
, _Deleter __d
)
208 : _M_ptr(__p
), _M_del(__d
)
218 get_deleter(const std::type_info
& __ti
)
220 return __ti
== typeid(_Deleter
) ? &_M_del
: 0;
224 _Sp_counted_base_impl(const _Sp_counted_base_impl
&);
225 _Sp_counted_base_impl
& operator=(const _Sp_counted_base_impl
&);
227 _Ptr _M_ptr
; // copy constructor must not throw
228 _Deleter _M_del
; // copy constructor must not throw
237 _Sp_counted_base
* _M_pi
;
239 friend class weak_count
;
244 : _M_pi(0) // nothrow
247 template<typename _Ptr
, typename _Deleter
>
248 shared_count(_Ptr __p
, _Deleter __d
)
253 _M_pi
= new _Sp_counted_base_impl
<_Ptr
, _Deleter
>(__p
, __d
);
257 __d(__p
); // delete __p
258 __throw_exception_again
;
262 // auto_ptr<_Tp> is special cased to provide the strong guarantee
264 template<typename _Tp
>
265 explicit shared_count(std::auto_ptr
<_Tp
>& __r
)
266 : _M_pi(new _Sp_counted_base_impl
<_Tp
*,
267 _Sp_deleter
<_Tp
> >(__r
.get(), _Sp_deleter
<_Tp
>()))
270 // throws bad_weak_ptr when __r.use_count() == 0
271 explicit shared_count(const weak_count
& __r
);
273 ~shared_count() // nothrow
279 shared_count(const shared_count
& __r
)
280 : _M_pi(__r
._M_pi
) // nothrow
283 _M_pi
->add_ref_copy();
287 operator=(const shared_count
& __r
) // nothrow
289 _Sp_counted_base
* __tmp
= __r
._M_pi
;
294 __tmp
->add_ref_copy();
302 void swap(shared_count
& __r
) // nothrow
304 _Sp_counted_base
* __tmp
= __r
._M_pi
;
310 use_count() const // nothrow
311 { return _M_pi
!= 0 ? _M_pi
->use_count() : 0; }
314 unique() const // nothrow
315 { return this->use_count() == 1; }
318 operator==(const shared_count
& __a
, const shared_count
& __b
)
319 { return __a
._M_pi
== __b
._M_pi
; }
322 operator<(const shared_count
& __a
, const shared_count
& __b
)
323 { return std::less
<_Sp_counted_base
*>()(__a
._M_pi
, __b
._M_pi
); }
326 get_deleter(const std::type_info
& __ti
) const
327 { return _M_pi
? _M_pi
->get_deleter(__ti
) : 0; }
334 _Sp_counted_base
* _M_pi
;
336 friend class shared_count
;
341 : _M_pi(0) // nothrow
344 weak_count(const shared_count
& __r
)
345 : _M_pi(__r
._M_pi
) // nothrow
348 _M_pi
->weak_add_ref();
351 weak_count(const weak_count
& __r
)
352 : _M_pi(__r
._M_pi
) // nothrow
355 _M_pi
->weak_add_ref();
358 ~weak_count() // nothrow
361 _M_pi
->weak_release();
365 operator=(const shared_count
& __r
) // nothrow
367 _Sp_counted_base
* __tmp
= __r
._M_pi
;
369 __tmp
->weak_add_ref();
371 _M_pi
->weak_release();
378 operator=(const weak_count
& __r
) // nothrow
380 _Sp_counted_base
* __tmp
= __r
._M_pi
;
382 __tmp
->weak_add_ref();
384 _M_pi
->weak_release();
391 swap(weak_count
& __r
) // nothrow
393 _Sp_counted_base
* __tmp
= __r
._M_pi
;
399 use_count() const // nothrow
400 { return _M_pi
!= 0 ? _M_pi
->use_count() : 0; }
403 operator==(const weak_count
& __a
, const weak_count
& __b
)
404 { return __a
._M_pi
== __b
._M_pi
; }
407 operator<(const weak_count
& __a
, const weak_count
& __b
)
408 { return std::less
<_Sp_counted_base
*>()(__a
._M_pi
, __b
._M_pi
); }
412 shared_count::shared_count(const weak_count
& __r
)
416 _M_pi
->add_ref_lock();
418 __throw_bad_weak_ptr();
423 template<typename _Tp
>
426 template<typename _Tp
>
429 template<typename _Tp
>
430 class enable_shared_from_this
;
432 struct __static_cast_tag
{};
433 struct __const_cast_tag
{};
434 struct __dynamic_cast_tag
{};
435 struct __polymorphic_cast_tag
{};
438 struct shared_ptr_traits
439 { typedef _Tp
& reference
; };
442 struct shared_ptr_traits
<void>
443 { typedef void reference
; };
446 struct shared_ptr_traits
<void const>
447 { typedef void reference
; };
450 struct shared_ptr_traits
<void volatile>
451 { typedef void reference
; };
454 struct shared_ptr_traits
<void const volatile>
455 { typedef void reference
; };
458 // enable_shared_from_this support
460 // friend of enable_shared_from_this
461 template<typename _Tp1
, typename _Tp2
>
463 __enable_shared_from_this(const shared_count
& __pn
,
464 const enable_shared_from_this
<_Tp1
>* __pe
,
468 __enable_shared_from_this(const shared_count
&, ...)
472 // get_deleter must be declared before friend declaration by shared_ptr.
473 template<typename _Del
, typename _Tp
>
474 _Del
* get_deleter(const shared_ptr
<_Tp
>&);
477 * @class shared_ptr <tr1/memory>
479 * A smart pointer with reference-counted copy semantics.
480 * The object pointed to is deleted when the last shared_ptr pointing to it
481 * is destroyed or reset.
483 template<typename _Tp
>
486 typedef typename shared_ptr_traits
<_Tp
>::reference _Reference
;
490 typedef _Tp element_type
;
492 /** @brief Construct an empty %shared_ptr.
493 * @post use_count()==0 && get()==0
496 : _M_ptr(0), _M_refcount() // never throws
499 /** @brief Construct a %shared_ptr that owns the pointer @a p.
500 * @param p A pointer that is convertible to element_type*.
501 * @post use_count() == 1 && get() == p
502 * @throw std::bad_alloc, in which case @c delete @a p is called.
504 template<typename _Tp1
>
505 explicit shared_ptr(_Tp1
* __p
)
506 : _M_ptr(__p
), _M_refcount(__p
, _Sp_deleter
<_Tp1
>())
508 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
509 // __glibcxx_function_requires(_CompleteConcept<_Tp1*>)
511 __enable_shared_from_this( _M_refcount
, __p
, __p
);
515 // Requirements: D's copy constructor and destructor must not throw
517 // shared_ptr will release p by calling d(p)
519 /** @brief Construct a %shared_ptr that owns the pointer @a p
520 * and the deleter @a d.
521 * @param p A pointer.
522 * @param d A deleter.
523 * @post use_count() == 1 && get() == p
524 * @throw std::bad_alloc, in which case @a d(p) is called.
526 template<typename _Tp1
, typename _Deleter
>
527 shared_ptr(_Tp1
* __p
, _Deleter __d
)
528 : _M_ptr(__p
), _M_refcount(__p
, __d
)
530 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
531 // TODO requires D is CopyConstructible and d(p) well-formed
533 __enable_shared_from_this( _M_refcount
, __p
, __p
);
536 // generated copy constructor, assignment, destructor are fine.
538 /** @brief If @a r is empty, constructs an empty %shared_ptr; otherwise
539 * construct a %shared_ptr that shares ownership with @a r.
540 * @param r A %shared_ptr.
541 * @post get() == r.get() && use_count() == r.use_count()
542 * @throw std::bad_alloc, in which case
544 template<typename _Tp1
>
545 shared_ptr(const shared_ptr
<_Tp1
>& __r
)
546 : _M_ptr(__r
._M_ptr
), _M_refcount(__r
._M_refcount
) // never throws
548 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
551 /** @brief Constructs a %shared_ptr that shares ownership with @a r
552 * and stores a copy of the pointer stored in @a r.
553 * @param r A weak_ptr.
554 * @post use_count() == r.use_count()
555 * @throw bad_weak_ptr when r.expired(),
556 * in which case the constructor has no effect.
558 template<typename _Tp1
>
559 explicit shared_ptr(const weak_ptr
<_Tp1
>& __r
)
560 : _M_refcount(__r
._M_refcount
) // may throw
562 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
563 // it is now safe to copy r__._M_ptr, as _M_refcount(__r._M_refcount)
569 * @post use_count() == 1 and r.get() == 0
571 template<typename _Tp1
>
572 explicit shared_ptr(std::auto_ptr
<_Tp1
>& __r
)
573 : _M_ptr(__r
.get()), _M_refcount()
575 // TODO requires r.release() convertible to _Tp*, Tp1 is complete,
576 // delete r.release() well-formed
577 _Tp1
* __tmp
= __r
.get();
578 _M_refcount
= shared_count(__r
);
580 __enable_shared_from_this( _M_refcount
, __tmp
, __tmp
);
583 template<typename _Tp1
>
584 shared_ptr(const shared_ptr
<_Tp1
>& __r
, __static_cast_tag
)
585 : _M_ptr(static_cast<element_type
*>(__r
._M_ptr
)),
586 _M_refcount(__r
._M_refcount
)
589 template<typename _Tp1
>
590 shared_ptr(const shared_ptr
<_Tp1
>& __r
, __const_cast_tag
)
591 : _M_ptr(const_cast<element_type
*>(__r
._M_ptr
)),
592 _M_refcount(__r
._M_refcount
)
595 template<typename _Tp1
>
596 shared_ptr(const shared_ptr
<_Tp1
>& __r
, __dynamic_cast_tag
)
597 : _M_ptr(dynamic_cast<element_type
*>(__r
._M_ptr
)),
598 _M_refcount(__r
._M_refcount
)
600 if (_M_ptr
== 0) // need to allocate new counter -- the cast failed
601 _M_refcount
= shared_count();
604 template<typename _Tp1
>
606 operator=(const shared_ptr
<_Tp1
>& __r
) // never throws
609 _M_refcount
= __r
._M_refcount
; // shared_count::op= doesn't throw
613 template<typename _Tp1
>
615 operator=(std::auto_ptr
<_Tp1
>& __r
)
617 shared_ptr(__r
).swap(*this);
622 reset() // never throws
623 { shared_ptr().swap(*this); }
625 template<typename _Tp1
>
627 reset(_Tp1
* __p
) // _Tp1 must be complete
629 _GLIBCXX_DEBUG_ASSERT(__p
== 0 || __p
!= _M_ptr
); // catch self-reset
631 shared_ptr(__p
).swap(*this);
634 template<typename _Tp1
, typename _Deleter
>
636 reset(_Tp1
* __p
, _Deleter __d
)
637 { shared_ptr(__p
, __d
).swap(*this); }
639 // error to instantiate if _Tp is [cv-qual] void
641 operator*() const // never throws
643 _GLIBCXX_DEBUG_ASSERT(_M_ptr
!= 0);
648 operator->() const // never throws
650 _GLIBCXX_DEBUG_ASSERT(_M_ptr
!= 0);
655 get() const // never throws
658 // implicit conversion to "bool"
660 typedef _Tp
* shared_ptr::*__unspecified_bool_type
;
663 operator __unspecified_bool_type() const // never throws
664 { return _M_ptr
== 0 ? 0 : &shared_ptr::_M_ptr
; }
667 unique() const // never throws
668 { return _M_refcount
.unique(); }
671 use_count() const // never throws
672 { return _M_refcount
.use_count(); }
675 swap(shared_ptr
<_Tp
>& __other
) // never throws
677 std::swap(_M_ptr
, __other
._M_ptr
);
678 _M_refcount
.swap(__other
._M_refcount
);
683 _M_get_deleter(const std::type_info
& __ti
) const
684 { return _M_refcount
.get_deleter(__ti
); }
686 template<typename _Tp1
>
688 _M_less(const shared_ptr
<_Tp1
>& __rhs
) const
689 { return _M_refcount
< __rhs
._M_refcount
; }
691 template<typename _Tp1
> friend class shared_ptr
;
692 template<typename _Tp1
> friend class weak_ptr
;
694 template<typename _Del
, typename _Tp1
>
695 friend _Del
* get_deleter(const shared_ptr
<_Tp1
>&);
697 // friends injected into enclosing namespace and found by ADL:
698 template<typename _Tp1
>
700 operator==(const shared_ptr
& __a
, const shared_ptr
<_Tp1
>& __b
)
701 { return __a
.get() == __b
.get(); }
703 template<typename _Tp1
>
705 operator!=(const shared_ptr
& __a
, const shared_ptr
<_Tp1
>& __b
)
706 { return __a
.get() != __b
.get(); }
708 template<typename _Tp1
>
710 operator<(const shared_ptr
& __a
, const shared_ptr
<_Tp1
>& __b
)
711 { return __a
._M_less(__b
); }
713 _Tp
* _M_ptr
; // contained pointer
714 shared_count _M_refcount
; // reference counter
717 // 2.2.3.8 shared_ptr specialized algorithms.
718 template<typename _Tp
>
720 swap(shared_ptr
<_Tp
>& __a
, shared_ptr
<_Tp
>& __b
)
723 // 2.2.3.9 shared_ptr casts
724 /** @warning The seemingly equivalent
725 * <code>shared_ptr<T>(static_cast<T*>(r.get()))</code>
726 * will eventually result in undefined behaviour,
727 * attempting to delete the same object twice.
729 template<typename _Tp
, typename _Tp1
>
731 static_pointer_cast(const shared_ptr
<_Tp1
>& __r
)
733 return shared_ptr
<_Tp
>(__r
, __static_cast_tag());
736 /** @warning The seemingly equivalent
737 * <code>shared_ptr<T>(const_cast<T*>(r.get()))</code>
738 * will eventually result in undefined behaviour,
739 * attempting to delete the same object twice.
741 template<typename _Tp
, typename _Tp1
>
743 const_pointer_cast(const shared_ptr
<_Tp1
>& __r
)
745 return shared_ptr
<_Tp
>(__r
, __const_cast_tag());
748 /** @warning The seemingly equivalent
749 * <code>shared_ptr<T>(dynamic_cast<T*>(r.get()))</code>
750 * will eventually result in undefined behaviour,
751 * attempting to delete the same object twice.
753 template<typename _Tp
, typename _Tp1
>
755 dynamic_pointer_cast(const shared_ptr
<_Tp1
>& __r
)
757 return shared_ptr
<_Tp
>(__r
, __dynamic_cast_tag());
760 // 2.2.3.7 shared_ptr I/O
761 template<typename _Ch
, typename _Tr
, typename _Tp
>
762 std::basic_ostream
<_Ch
, _Tr
>&
763 operator<<(std::basic_ostream
<_Ch
, _Tr
>& __os
, const shared_ptr
<_Tp
>& __p
)
769 // 2.2.3.10 shared_ptr get_deleter (experimental)
770 template<typename _Del
, typename _Tp
>
772 get_deleter(const shared_ptr
<_Tp
>& __p
)
773 { return static_cast<_Del
*>(__p
._M_get_deleter(typeid(_Del
))); }
776 template<typename _Tp
>
781 typedef _Tp element_type
;
784 : _M_ptr(0), _M_refcount() // never throws
787 // generated copy constructor, assignment, destructor are fine
790 // The "obvious" converting constructor implementation:
793 // weak_ptr(weak_ptr<Y> const & r)
794 // : _M_ptr(r._M_ptr), _M_refcount(r._M_refcount) // never throws
797 // has a serious problem.
799 // r._M_ptr may already have been invalidated. The _M_ptr(r._M_ptr)
800 // conversion may require access to *r._M_ptr (virtual inheritance).
802 // It is not possible to avoid spurious access violations since
803 // in multithreaded programs r._M_ptr may be invalidated at any point.
806 template<typename _Tp1
>
807 weak_ptr(const weak_ptr
<_Tp1
>& r
)
808 : _M_refcount(r
._M_refcount
) // never throws
810 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
811 _M_ptr
= r
.lock().get();
814 template<typename _Tp1
>
815 weak_ptr(const shared_ptr
<_Tp1
>& r
)
816 : _M_ptr(r
._M_ptr
), _M_refcount(r
._M_refcount
) // never throws
818 __glibcxx_function_requires(_ConvertibleConcept
<_Tp1
*, _Tp
*>)
821 template<typename _Tp1
>
823 operator=(const weak_ptr
<_Tp1
>& r
) // never throws
825 _M_ptr
= r
.lock().get();
826 _M_refcount
= r
._M_refcount
;
830 template<typename _Tp1
>
832 operator=(const shared_ptr
<_Tp1
>& r
) // never throws
835 _M_refcount
= r
._M_refcount
;
840 lock() const // never throws
844 // optimization: avoid throw overhead
846 return shared_ptr
<element_type
>();
850 return shared_ptr
<element_type
>(*this);
852 catch (const bad_weak_ptr
&)
854 // Q: how can we get here?
855 // A: another thread may have invalidated r after the
856 // use_count test above.
857 return shared_ptr
<element_type
>();
862 // optimization: avoid try/catch overhead when single threaded
863 return expired() ? shared_ptr
<element_type
>()
864 : shared_ptr
<element_type
>(*this);
870 use_count() const // never throws
871 { return _M_refcount
.use_count(); }
874 expired() const // never throws
875 { return _M_refcount
.use_count() == 0; }
878 reset() // never throws
879 { weak_ptr().swap(*this); }
882 swap(weak_ptr
& __s
) // never throws
884 std::swap(_M_ptr
, __s
._M_ptr
);
885 _M_refcount
.swap(__s
._M_refcount
);
890 template<typename _Tp1
>
892 _M_less(const weak_ptr
<_Tp1
>& __rhs
) const
893 { return _M_refcount
< __rhs
._M_refcount
; }
895 // used by __enable_shared_from_this
897 _M_assign(_Tp
* __ptr
, const shared_count
& __refcount
)
900 _M_refcount
= __refcount
;
903 // friend injected into namespace and found by ADL
905 template<typename _Tp1
>
907 operator<(const weak_ptr
& __lhs
, const weak_ptr
<_Tp1
>& __rhs
)
908 { return __lhs
._M_less(__rhs
); }
910 template<typename _Tp1
> friend class weak_ptr
;
911 template<typename _Tp1
> friend class shared_ptr
;
912 friend class enable_shared_from_this
<_Tp
>;
914 _Tp
* _M_ptr
; // contained pointer
915 weak_count _M_refcount
; // reference counter
919 // 2.2.4.7 weak_ptr specialized algorithms.
920 template<typename _Tp
>
922 swap(weak_ptr
<_Tp
>& __a
, weak_ptr
<_Tp
>& __b
)
926 template<typename _Tp
>
927 class enable_shared_from_this
931 enable_shared_from_this()
934 enable_shared_from_this(const enable_shared_from_this
&)
937 enable_shared_from_this
&
938 operator=(const enable_shared_from_this
&)
941 ~enable_shared_from_this()
949 shared_ptr
<_Tp
> __p(this->_M_weak_this
);
953 shared_ptr
<const _Tp
>
954 shared_from_this() const
956 shared_ptr
<const _Tp
> __p(this->_M_weak_this
);
961 template<typename _Tp1
>
963 _M_weak_assign(_Tp1
* __p
, const shared_count
& __n
) const
964 { _M_weak_this
._M_assign(__p
, __n
); }
966 template<typename _Tp1
>
968 __enable_shared_from_this(const shared_count
& __pn
,
969 const enable_shared_from_this
* __pe
,
973 __pe
->_M_weak_assign(const_cast<_Tp1
*>(__px
), __pn
);
976 mutable weak_ptr
<_Tp
> _M_weak_this
;
979 _GLIBCXX_END_NAMESPACE