/usr/include/boost/smart_ptr
NameSizeModeActions
detail/-0755rm
allocate_local_shared_array.hpp56550644editdlrm
allocate_shared_array.hpp99590644editdlrm
allocate_unique.hpp123690644editdlrm
atomic_shared_ptr.hpp58150644editdlrm
bad_weak_ptr.hpp17440644editdlrm
enable_shared_from.hpp11840644editdlrm
enable_shared_from_raw.hpp44790644editdlrm
enable_shared_from_this.hpp21750644editdlrm
intrusive_ptr.hpp94270644editdlrm
intrusive_ref_counter.hpp58170644editdlrm
local_shared_ptr.hpp193770644editdlrm
make_local_shared.hpp5760644editdlrm
make_local_shared_array.hpp21790644editdlrm
make_local_shared_object.hpp47870644editdlrm
make_shared.hpp7070644editdlrm
make_shared_array.hpp19960644editdlrm
make_shared_object.hpp246220644editdlrm
make_unique.hpp17830644editdlrm
owner_equal_to.hpp6710644editdlrm
owner_hash.hpp6000644editdlrm
owner_less.hpp8530644editdlrm
scoped_array.hpp33010644editdlrm
scoped_ptr.hpp40820644editdlrm
shared_array.hpp72520644editdlrm
shared_ptr.hpp311990644editdlrm
weak_ptr.hpp75820644editdlrm
Edit: /usr/include/boost/smart_ptr/enable_shared_from_raw.hpp (4479B)
#ifndef BOOST_ENABLE_SHARED_FROM_RAW_HPP_INCLUDED #define BOOST_ENABLE_SHARED_FROM_RAW_HPP_INCLUDED // // enable_shared_from_raw.hpp // // Copyright 2002, 2009, 2014 Peter Dimov // Copyright 2008-2009 Frank Mori Hess // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // #include #include #include #include #include namespace boost { template boost::shared_ptr shared_from_raw(T *); template boost::weak_ptr weak_from_raw(T *); namespace detail { template< class X, class Y > inline void sp_enable_shared_from_this( boost::shared_ptr * ppx, Y const * py, boost::enable_shared_from_raw const * pe ); } // namespace detail class enable_shared_from_raw { protected: enable_shared_from_raw() { } enable_shared_from_raw( enable_shared_from_raw const & ) { } enable_shared_from_raw & operator=( enable_shared_from_raw const & ) { return *this; } ~enable_shared_from_raw() { BOOST_ASSERT( shared_this_.use_count() <= 1 ); // make sure no dangling shared_ptr objects exist } private: void init_if_expired() const { if( weak_this_.expired() ) { shared_this_.reset( static_cast(0), detail::esft2_deleter_wrapper() ); weak_this_ = shared_this_; } } void init_if_empty() const { if( weak_this_._empty() ) { shared_this_.reset( static_cast(0), detail::esft2_deleter_wrapper() ); weak_this_ = shared_this_; } } #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS public: #else private: template friend class shared_ptr; template friend boost::shared_ptr shared_from_raw(T *); template friend boost::weak_ptr weak_from_raw(T *); template< class X, class Y > friend inline void detail::sp_enable_shared_from_this( boost::shared_ptr * ppx, Y const * py, boost::enable_shared_from_raw const * pe ); #endif shared_ptr shared_from_this() const { init_if_expired(); return shared_ptr( weak_this_ ); } shared_ptr shared_from_this() const volatile { return const_cast< enable_shared_from_raw const * >( this )->shared_from_this(); } weak_ptr weak_from_this() const { init_if_empty(); return weak_this_; } weak_ptr weak_from_this() const volatile { return const_cast< enable_shared_from_raw const * >( this )->weak_from_this(); } // Note: invoked automatically by shared_ptr; do not call template void _internal_accept_owner( shared_ptr * ppx, Y * ) const { BOOST_ASSERT( ppx != 0 ); if( weak_this_.expired() ) { weak_this_ = *ppx; } else if( shared_this_.use_count() != 0 ) { BOOST_ASSERT( ppx->unique() ); // no weak_ptrs should exist either, but there's no way to check that detail::esft2_deleter_wrapper * pd = boost::get_deleter( shared_this_ ); BOOST_ASSERT( pd != 0 ); pd->set_deleter( *ppx ); ppx->reset( shared_this_, ppx->get() ); shared_this_.reset(); } } mutable weak_ptr weak_this_; private: mutable shared_ptr shared_this_; }; template boost::shared_ptr shared_from_raw(T *p) { BOOST_ASSERT(p != 0); return boost::shared_ptr(p->enable_shared_from_raw::shared_from_this(), p); } template boost::weak_ptr weak_from_raw(T *p) { BOOST_ASSERT(p != 0); boost::weak_ptr result(p->enable_shared_from_raw::weak_from_this(), p); return result; } namespace detail { template< class X, class Y > inline void sp_enable_shared_from_this( boost::shared_ptr * ppx, Y const * py, boost::enable_shared_from_raw const * pe ) { if( pe != 0 ) { pe->_internal_accept_owner( ppx, const_cast< Y* >( py ) ); } } } // namepsace detail } // namespace boost #endif // #ifndef BOOST_ENABLE_SHARED_FROM_RAW_HPP_INCLUDED