21 #ifndef Om_Macro_Precompilation_
24 #include "boost/checked_delete.hpp"
25 #include "boost/integer_traits.hpp"
32 template <typename ThisOwnerCount>
35 Om::Shareable<ThisOwnerCount>
40 inline Type_::~Shareable() {
42 !this->thisOwnerCount &&
43 "Non-zero owner count."
48 inline ThisOwnerCount Type_::GetOwnerCount()
const {
49 return this->thisOwnerCount;
55 inline Type_::Shareable():
59 inline Type_::Shareable(Shareable
const &):
63 inline Type_ & Type_::operator =(Shareable
const &) {
70 inline void Type_::DecrementOwnerCount() {
72 this->thisOwnerCount &&
73 "Owner count underflow."
75 --this->thisOwnerCount;
79 inline void Type_::IncrementOwnerCount() {
81 boost::integer_traits<ThisOwnerCount>::const_max == this->thisOwnerCount
83 throw std::overflow_error(
"Owner count overflow.");
85 ++this->thisOwnerCount;
93 template <
typename TheOwnerCount>
95 Shareable<TheOwnerCount> *
const thePointee
99 "The pointer cannot be null."
101 thePointee->IncrementOwnerCount();
104 template <
typename TheOwnerCount>
106 Shareable<TheOwnerCount> *
const thePointee
110 "The pointer cannot be null."
112 thePointee->DecrementOwnerCount();
113 if (!thePointee->thisOwnerCount) {
114 boost::checked_delete(thePointee);
void intrusive_ptr_add_ref(Shareable< TheOwnerCount > *const)
void intrusive_ptr_release(Shareable< TheOwnerCount > *const)