1 #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // detail/sp_counted_base_nt.hpp
13 // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
14 // Copyright 2004-2005 Peter Dimov
16 // Distributed under the Boost Software License, Version 1.0. (See
17 // accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
21 #include <boost/detail/sp_typeinfo.hpp>
33 sp_counted_base( sp_counted_base const & );
34 sp_counted_base & operator= ( sp_counted_base const & );
36 long use_count_; // #shared
37 long weak_count_; // #weak + (#shared != 0)
41 sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
45 virtual ~sp_counted_base() // nothrow
49 // dispose() is called when use_count_ drops to zero, to release
50 // the resources managed by *this.
52 virtual void dispose() = 0; // nothrow
54 // destroy() is called when weak_count_ drops to zero.
56 virtual void destroy() // nothrow
61 virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
62 virtual void * get_untyped_deleter() = 0;
69 bool add_ref_lock() // true on success
71 if( use_count_ == 0 ) return false;
76 void release() // nothrow
78 if( --use_count_ == 0 )
85 void weak_add_ref() // nothrow
90 void weak_release() // nothrow
92 if( --weak_count_ == 0 )
98 long use_count() const // nothrow
104 } // namespace detail
108 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED