1#ifndef CYTNX_INTRUSIVE_PTR_BASE_H_
2#define CYTNX_INTRUSIVE_PTR_BASE_H_
6#include <boost/smart_ptr/intrusive_ptr.hpp>
7#include <boost/checked_delete.hpp>
8#include <boost/detail/atomic_count.hpp>
13 class intrusive_ptr_base;
22 void intrusive_ptr_add_ref(
const intrusive_ptr_base<T> *s);
24 void intrusive_ptr_release(
const intrusive_ptr_base<T> *s);
27 class intrusive_ptr_base {
36 intrusive_ptr_base(intrusive_ptr_base<T>
const &) : ref_count(0) {
41 intrusive_ptr_base &operator=(intrusive_ptr_base
const &rhs) {
46 boost::intrusive_ptr<T> self() {
return boost::intrusive_ptr<T>((T *)
this); }
48 boost::intrusive_ptr<const T> self()
const {
49 return boost::intrusive_ptr<const T>((T
const *)
this);
52 int refcount()
const {
return ref_count; }
56 friend void intrusive_ptr_add_ref(
const intrusive_ptr_base<U> *s);
58 friend void intrusive_ptr_release(
const intrusive_ptr_base<U> *s);
61 mutable boost::detail::atomic_count ref_count;
65 void intrusive_ptr_add_ref(
const intrusive_ptr_base<T> *s) {
67 assert(s->ref_count >= 0);
72 void intrusive_ptr_release(
const intrusive_ptr_base<T> *s) {
74 assert(s->ref_count > 0);
75 if (--s->ref_count == 0) boost::checked_delete(
static_cast<T
const *
>(s));
Definition Accessor.hpp:12