1 #ifndef BOOST_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
2 #define BOOST_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)
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( std::type_info const & ti ) = 0;
68 bool add_ref_lock() // true on success
70 if( use_count_ == 0 ) return false;
75 void release() // nothrow
77 if( --use_count_ == 0 )
84 void weak_add_ref() // nothrow
89 void weak_release() // nothrow
91 if( --weak_count_ == 0 )
97 long use_count() const // nothrow
103 } // namespace detail
107 #endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED