STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | List of all members
shared_ptr< _Ty > Class Template Reference
Inheritance diagram for shared_ptr< _Ty >:
_Ptr_base< _Ty >

Public Types

typedef shared_ptr< _Ty > _Myt
 
typedef _Ptr_base< _Ty > _Mybase
 
- Public Types inherited from _Ptr_base< _Ty >
typedef _Ptr_base< _Ty > _Myt
 
typedef _Ty element_type
 

Public Member Functions

 shared_ptr () _NOEXCEPT
 
template<class _Ux >
 shared_ptr (_Ux *_Px)
 
template<class _Ux , class _Dx >
 shared_ptr (_Ux *_Px, _Dx _Dt)
 
 shared_ptr (nullptr_t)
 
template<class _Dx >
 shared_ptr (nullptr_t, _Dx _Dt)
 
template<class _Dx , class _Alloc >
 shared_ptr (nullptr_t, _Dx _Dt, _Alloc _Ax)
 
template<class _Ux , class _Dx , class _Alloc >
 shared_ptr (_Ux *_Px, _Dx _Dt, _Alloc _Ax)
 
template<class _Ty2 >
 shared_ptr (const shared_ptr< _Ty2 > &_Right, _Ty *_Px) _NOEXCEPT
 
 shared_ptr (const _Myt &_Other) _NOEXCEPT
 
template<class _Ty2 , class = typename enable_if<is_convertible<_Ty2 *, _Ty *>::value, void>::type>
 shared_ptr (const shared_ptr< _Ty2 > &_Other) _NOEXCEPT
 
template<class _Ty2 >
 shared_ptr (const weak_ptr< _Ty2 > &_Other, bool _Throw=true)
 
template<class _Ty2 >
 shared_ptr (auto_ptr< _Ty2 > &&_Other)
 
template<class _Ty2 >
 shared_ptr (const shared_ptr< _Ty2 > &_Other, const _Static_tag &_Tag)
 
template<class _Ty2 >
 shared_ptr (const shared_ptr< _Ty2 > &_Other, const _Const_tag &_Tag)
 
template<class _Ty2 >
 shared_ptr (const shared_ptr< _Ty2 > &_Other, const _Dynamic_tag &_Tag)
 
 shared_ptr (_Myt &&_Right) _NOEXCEPT
 
template<class _Ty2 , class = typename enable_if<is_convertible<_Ty2 *, _Ty *>::value, void>::type>
 shared_ptr (shared_ptr< _Ty2 > &&_Right) _NOEXCEPT
 
template<class _Ux , class _Dx >
 shared_ptr (unique_ptr< _Ux, _Dx > &&_Right)
 
template<class _Ux , class _Dx >
_Mytoperator= (unique_ptr< _Ux, _Dx > &&_Right)
 
_Mytoperator= (_Myt &&_Right) _NOEXCEPT
 
template<class _Ty2 >
_Mytoperator= (shared_ptr< _Ty2 > &&_Right) _NOEXCEPT
 
 ~shared_ptr () _NOEXCEPT
 
_Mytoperator= (const _Myt &_Right) _NOEXCEPT
 
template<class _Ty2 >
_Mytoperator= (const shared_ptr< _Ty2 > &_Right) _NOEXCEPT
 
template<class _Ty2 >
_Mytoperator= (auto_ptr< _Ty2 > &&_Right)
 
void reset () _NOEXCEPT
 
template<class _Ux >
void reset (_Ux *_Px)
 
template<class _Ux , class _Dx >
void reset (_Ux *_Px, _Dx _Dt)
 
template<class _Ux , class _Dx , class _Alloc >
void reset (_Ux *_Px, _Dx _Dt, _Alloc _Ax)
 
void swap (_Myt &_Other) _NOEXCEPT
 
_Ty * get () const _NOEXCEPT
 
add_reference< _Ty >::type operator* () const _NOEXCEPT
 
_Ty * operator-> () const _NOEXCEPT
 
bool unique () const _NOEXCEPT
 
 operator bool () const _NOEXCEPT
 
template<class _Ux >
void _Resetp0 (_Ux *_Px, _Ref_count_base *_Rx)
 
- Public Member Functions inherited from _Ptr_base< _Ty >
 _Ptr_base ()
 
 _Ptr_base (_Myt &&_Right)
 
template<class _Ty2 >
 _Ptr_base (_Ptr_base< _Ty2 > &&_Right)
 
_Mytoperator= (_Myt &&_Right)
 
void _Assign_rv (_Myt &&_Right)
 
long use_count () const _NOEXCEPT
 
void _Swap (_Ptr_base &_Right)
 
template<class _Ty2 >
bool owner_before (const _Ptr_base< _Ty2 > &_Right) const
 
void_Get_deleter (const _XSTD2 type_info &_Typeid) const
 
_Ty * _Get () const
 
bool _Expired () const
 
void _Decref ()
 
void _Reset ()
 
template<class _Ty2 >
void _Reset (const _Ptr_base< _Ty2 > &_Other)
 
template<class _Ty2 >
void _Reset (const _Ptr_base< _Ty2 > &_Other, bool _Throw)
 
template<class _Ty2 >
void _Reset (const _Ptr_base< _Ty2 > &_Other, const _Static_tag &)
 
template<class _Ty2 >
void _Reset (const _Ptr_base< _Ty2 > &_Other, const _Const_tag &)
 
template<class _Ty2 >
void _Reset (const _Ptr_base< _Ty2 > &_Other, const _Dynamic_tag &)
 
template<class _Ty2 >
void _Reset (auto_ptr< _Ty2 > &&_Other)
 
template<class _Ty2 >
void _Reset (_Ty *_Ptr, const _Ptr_base< _Ty2 > &_Other)
 
void _Reset (_Ty *_Other_ptr, _Ref_count_base *_Other_rep)
 
void _Reset (_Ty *_Other_ptr, _Ref_count_base *_Other_rep, bool _Throw)
 
void _Reset0 (_Ty *_Other_ptr, _Ref_count_base *_Other_rep)
 
void _Decwref ()
 
void _Resetw ()
 
template<class _Ty2 >
void _Resetw (const _Ptr_base< _Ty2 > &_Other)
 
template<class _Ty2 >
void _Resetw (const _Ty2 *_Other_ptr, _Ref_count_base *_Other_rep)
 
template<class _Ty2 >
void _Resetw (_Ty2 *_Other_ptr, _Ref_count_base *_Other_rep)
 

Private Member Functions

template<class _Ux >
void _Resetp (_Ux *_Px)
 
template<class _Ux , class _Dx >
void _Resetp (_Ux *_Px, _Dx _Dt)
 
template<class _Ux , class _Dx , class _Alloc >
void _Resetp (_Ux *_Px, _Dx _Dt, _Alloc _Ax)
 

Member Typedef Documentation

template<class _Ty>
typedef _Ptr_base<_Ty> shared_ptr< _Ty >::_Mybase
template<class _Ty>
typedef shared_ptr<_Ty> shared_ptr< _Ty >::_Myt

Constructor & Destructor Documentation

template<class _Ty>
shared_ptr< _Ty >::shared_ptr ( )
inline
476  { // construct empty shared_ptr
477  }
template<class _Ty>
template<class _Ux >
shared_ptr< _Ty >::shared_ptr ( _Ux *  _Px)
inlineexplicit
481  { // construct shared_ptr object that owns _Px
482  _Resetp(_Px);
483  }
void _Resetp(_Ux *_Px)
Definition: memory:691
template<class _Ty>
template<class _Ux , class _Dx >
shared_ptr< _Ty >::shared_ptr ( _Ux *  _Px,
_Dx  _Dt 
)
inline
488  { // construct with _Px, deleter
489  _Resetp(_Px, _Dt);
490  }
void _Resetp(_Ux *_Px)
Definition: memory:691
template<class _Ty>
shared_ptr< _Ty >::shared_ptr ( nullptr_t  )
inline
493  { // construct empty shared_ptr
494  }
template<class _Ty>
template<class _Dx >
shared_ptr< _Ty >::shared_ptr ( nullptr_t  ,
_Dx  _Dt 
)
inline
498  { // construct with nullptr, deleter
499  _Resetp((_Ty *)0, _Dt);
500  }
void _Resetp(_Ux *_Px)
Definition: memory:691
template<class _Ty>
template<class _Dx , class _Alloc >
shared_ptr< _Ty >::shared_ptr ( nullptr_t  ,
_Dx  _Dt,
_Alloc  _Ax 
)
inline
505  { // construct with nullptr, deleter, allocator
506  _Resetp((_Ty *)0, _Dt, _Ax);
507  }
void _Resetp(_Ux *_Px)
Definition: memory:691
template<class _Ty>
template<class _Ux , class _Dx , class _Alloc >
shared_ptr< _Ty >::shared_ptr ( _Ux *  _Px,
_Dx  _Dt,
_Alloc  _Ax 
)
inline
513  { // construct with _Px, deleter, allocator
514  _Resetp(_Px, _Dt, _Ax);
515  }
void _Resetp(_Ux *_Px)
Definition: memory:691
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( const shared_ptr< _Ty2 > &  _Right,
_Ty *  _Px 
)
inline
519  { // construct shared_ptr object that aliases _Right
520  this->_Reset(_Px, _Right);
521  }
void _Reset()
Definition: memory:346
template<class _Ty>
shared_ptr< _Ty >::shared_ptr ( const _Myt _Other)
inline
524  { // construct shared_ptr object that owns same resource as _Other
525  this->_Reset(_Other);
526  }
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 , class = typename enable_if<is_convertible<_Ty2 *, _Ty *>::value, void>::type>
shared_ptr< _Ty >::shared_ptr ( const shared_ptr< _Ty2 > &  _Other)
inline
532  { // construct shared_ptr object that owns same resource as _Other
533  this->_Reset(_Other);
534  }
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( const weak_ptr< _Ty2 > &  _Other,
bool  _Throw = true 
)
inlineexplicit
539  { // construct shared_ptr object that owns resource *_Other
540  this->_Reset(_Other, _Throw);
541  }
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( auto_ptr< _Ty2 > &&  _Other)
inline
545  { // construct shared_ptr object that owns *_Other.get()
546  this->_Reset(_STD move(_Other));
547  }
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( const shared_ptr< _Ty2 > &  _Other,
const _Static_tag _Tag 
)
inline
551  { // construct shared_ptr object for static_pointer_cast
552  this->_Reset(_Other, _Tag);
553  }
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( const shared_ptr< _Ty2 > &  _Other,
const _Const_tag _Tag 
)
inline
557  { // construct shared_ptr object for const_pointer_cast
558  this->_Reset(_Other, _Tag);
559  }
void _Reset()
Definition: memory:346
template<class _Ty>
template<class _Ty2 >
shared_ptr< _Ty >::shared_ptr ( const shared_ptr< _Ty2 > &  _Other,
const _Dynamic_tag _Tag 
)
inline
563  { // construct shared_ptr object for dynamic_pointer_cast
564  this->_Reset(_Other, _Tag);
565  }
void _Reset()
Definition: memory:346
template<class _Ty>
shared_ptr< _Ty >::shared_ptr ( _Myt &&  _Right)
inline
568  : _Mybase(_STD forward<_Myt>(_Right))
569  { // construct shared_ptr object that takes resource from _Right
570  }
_Ptr_base< _Ty > _Mybase
Definition: memory:473
const _Ty & _Right
Definition: algorithm:4087
template<class _Ty>
template<class _Ty2 , class = typename enable_if<is_convertible<_Ty2 *, _Ty *>::value, void>::type>
shared_ptr< _Ty >::shared_ptr ( shared_ptr< _Ty2 > &&  _Right)
inline
576  : _Mybase(_STD forward<shared_ptr<_Ty2> >(_Right))
577  { // construct shared_ptr object that takes resource from _Right
578  }
Definition: memory:245
_Ptr_base< _Ty > _Mybase
Definition: memory:473
template<class _Ty>
template<class _Ux , class _Dx >
shared_ptr< _Ty >::shared_ptr ( unique_ptr< _Ux, _Dx > &&  _Right)
inline
583  { // construct from unique_ptr
584  _Resetp(_Right.release(), _Right.get_deleter());
585  }
void _Resetp(_Ux *_Px)
Definition: memory:691
pointer release() _NOEXCEPT
Definition: memory:1471
template<class _Ty>
shared_ptr< _Ty >::~shared_ptr ( )
inline
609  { // release resource
610  this->_Decref();
611  }
void _Decref()
Definition: memory:340

Member Function Documentation

template<class _Ty>
template<class _Ux >
void shared_ptr< _Ty >::_Resetp ( _Ux *  _Px)
inlineprivate
692  { // release, take ownership of _Px
693  _TRY_BEGIN // allocate control block and reset
694  _Resetp0(_Px, new _Ref_count<_Ux>(_Px));
695  _CATCH_ALL // allocation failed, delete resource
696  delete _Px;
697  _RERAISE;
698  _CATCH_END
699  }
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
void _Resetp0(_Ux *_Px, _Ref_count_base *_Rx)
Definition: memory:733
#define _CATCH_ALL
Definition: xstddef:62
Definition: memory:147
#define _RERAISE
Definition: xstddef:74
template<class _Ty>
template<class _Ux , class _Dx >
void shared_ptr< _Ty >::_Resetp ( _Ux *  _Px,
_Dx  _Dt 
)
inlineprivate
704  { // release, take ownership of _Px, deleter _Dt
705  _TRY_BEGIN // allocate control block and reset
706  _Resetp0(_Px, new _Ref_count_del<_Ux, _Dx>(_Px, _Dt));
707  _CATCH_ALL // allocation failed, delete resource
708  _Dt(_Px);
709  _RERAISE;
710  _CATCH_END
711  }
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
Definition: memory:173
void _Resetp0(_Ux *_Px, _Ref_count_base *_Rx)
Definition: memory:733
#define _CATCH_ALL
Definition: xstddef:62
#define _RERAISE
Definition: xstddef:74
template<class _Ty>
template<class _Ux , class _Dx , class _Alloc >
void shared_ptr< _Ty >::_Resetp ( _Ux *  _Px,
_Dx  _Dt,
_Alloc  _Ax 
)
inlineprivate
717  { // release, take ownership of _Px, deleter _Dt, allocator _Ax
719  typename _Alloc::template rebind<_Refd>::other _Al = _Ax;
720 
721  _TRY_BEGIN // allocate control block and reset
722  _Refd *_Ptr = _Al.allocate(1);
723  ::new (_Ptr) _Refd(_Px, _Dt, _Al);
724  _Resetp0(_Px, _Ptr);
725  _CATCH_ALL // allocation failed, delete resource
726  _Dt(_Px);
727  _RERAISE;
728  _CATCH_END
729  }
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
_Ty * _Ptr
Definition: memory:460
void _Resetp0(_Ux *_Px, _Ref_count_base *_Rx)
Definition: memory:733
Definition: memory:206
#define _CATCH_ALL
Definition: xstddef:62
#define _RERAISE
Definition: xstddef:74
template<class _Ty>
template<class _Ux >
void shared_ptr< _Ty >::_Resetp0 ( _Ux *  _Px,
_Ref_count_base _Rx 
)
inline
734  { // release resource and take ownership of _Px
735  this->_Reset0(_Px, _Rx);
736  _Enable_shared(_Px, _Rx);
737  }
void _Enable_shared(_Ty *_Ptr, _Ref_count_base *_Refptr, typename _Ty::_EStype *=0)
Definition: memory:257
void _Reset0(_Ty *_Other_ptr, _Ref_count_base *_Other_rep)
Definition: memory:417
template<class _Ty>
_Ty* shared_ptr< _Ty >::get ( ) const
inline
665  { // return pointer to resource
666  return (this->_Get());
667  }
_Ty * _Get() const
Definition: memory:330
template<class _Ty>
shared_ptr< _Ty >::operator bool ( ) const
inlineexplicit
685  { // test if shared_ptr object owns no resource
686  return (this->_Get() != 0);
687  }
_Ty * _Get() const
Definition: memory:330
template<class _Ty>
add_reference<_Ty>::type shared_ptr< _Ty >::operator* ( ) const
inline
670  { // return reference to resource
671  return (*this->_Get());
672  }
_Ty * _Get() const
Definition: memory:330
template<class _Ty>
_Ty* shared_ptr< _Ty >::operator-> ( ) const
inline
675  { // return pointer to resource
676  return (this->_Get());
677  }
_Ty * _Get() const
Definition: memory:330
template<class _Ty>
template<class _Ux , class _Dx >
_Myt& shared_ptr< _Ty >::operator= ( unique_ptr< _Ux, _Dx > &&  _Right)
inline
590  { // move from unique_ptr
591  shared_ptr(_STD move(_Right)).swap(*this);
592  return (*this);
593  }
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
_Myt& shared_ptr< _Ty >::operator= ( _Myt &&  _Right)
inline
596  { // construct shared_ptr object that takes resource from _Right
597  shared_ptr(_STD move(_Right)).swap(*this);
598  return (*this);
599  }
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
shared_ptr() _NOEXCEPT
Definition: memory:475
const _Ty & _Right
Definition: algorithm:4087
template<class _Ty>
template<class _Ty2 >
_Myt& shared_ptr< _Ty >::operator= ( shared_ptr< _Ty2 > &&  _Right)
inline
603  { // construct shared_ptr object that takes resource from _Right
604  shared_ptr(_STD move(_Right)).swap(*this);
605  return (*this);
606  }
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
_Myt& shared_ptr< _Ty >::operator= ( const _Myt _Right)
inline
614  { // assign shared ownership of resource owned by _Right
615  shared_ptr(_Right).swap(*this);
616  return (*this);
617  }
shared_ptr() _NOEXCEPT
Definition: memory:475
const _Ty & _Right
Definition: algorithm:4087
template<class _Ty>
template<class _Ty2 >
_Myt& shared_ptr< _Ty >::operator= ( const shared_ptr< _Ty2 > &  _Right)
inline
621  { // assign shared ownership of resource owned by _Right
622  shared_ptr(_Right).swap(*this);
623  return (*this);
624  }
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
template<class _Ty2 >
_Myt& shared_ptr< _Ty >::operator= ( auto_ptr< _Ty2 > &&  _Right)
inline
628  { // assign ownership of resource pointed to by _Right
629  shared_ptr(_STD move(_Right)).swap(*this);
630  return (*this);
631  }
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
void shared_ptr< _Ty >::reset ( )
inline
634  { // release resource and convert to empty shared_ptr object
635  shared_ptr().swap(*this);
636  }
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
template<class _Ux >
void shared_ptr< _Ty >::reset ( _Ux *  _Px)
inline
640  { // release, take ownership of _Px
641  shared_ptr(_Px).swap(*this);
642  }
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
template<class _Ux , class _Dx >
void shared_ptr< _Ty >::reset ( _Ux *  _Px,
_Dx  _Dt 
)
inline
647  { // release, take ownership of _Px, with deleter _Dt
648  shared_ptr(_Px, _Dt).swap(*this);
649  }
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
template<class _Ux , class _Dx , class _Alloc >
void shared_ptr< _Ty >::reset ( _Ux *  _Px,
_Dx  _Dt,
_Alloc  _Ax 
)
inline
655  { // release, take ownership of _Px, with deleter _Dt, allocator _Ax
656  shared_ptr(_Px, _Dt, _Ax).swap(*this);
657  }
shared_ptr() _NOEXCEPT
Definition: memory:475
template<class _Ty>
void shared_ptr< _Ty >::swap ( _Myt _Other)
inline
660  { // swap pointers
661  this->_Swap(_Other);
662  }
void _Swap(_Ptr_base &_Right)
Definition: memory:313
template<class _Ty>
bool shared_ptr< _Ty >::unique ( ) const
inline
680  { // return true if no other shared_ptr object owns this resource
681  return (this->use_count() == 1);
682  }
long use_count() const _NOEXCEPT
Definition: memory:308

The documentation for this class was generated from the following file: