1 #ifndef XAPIAN_INCLUDED_INTRUSIVE_PTR_H 2 #define XAPIAN_INCLUDED_INTRUSIVE_PTR_H 39 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD 40 # error Never use <xapian/intrusive_ptr.h> directly; include <xapian.h> instead. 95 if( px != 0 ) ++px->_refs;
102 if( px != 0 ) ++px->_refs;
107 if( px != 0 ) ++px->_refs;
112 if( px != 0 && --px->_refs == 0 )
delete px;
115 #ifdef XAPIAN_MOVE_SEMANTICS 123 this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*
this);
145 this_type(rhs).
swap(*
this);
151 this_type(rhs).
swap(*
this);
184 return a.
get() == b.
get();
189 return a.
get() != b.
get();
287 if( counting ) ++px->_refs;
292 : px( rhs.get() ), counting( rhs.counting )
294 if( counting ) ++px->_refs;
298 : px( rhs.px ), counting( rhs.counting )
300 if( counting ) ++px->_refs;
305 if( counting && --px->_refs == 1 )
delete px;
308 #ifdef XAPIAN_MOVE_SEMANTICS 310 : px( rhs.px ), counting( rhs.counting )
318 this_type( static_cast< opt_intrusive_ptr && >( rhs ) ).swap(*
this);
326 : px( rhs.px ), counting( rhs.counting )
342 this_type(rhs).
swap(*
this);
348 this_type(rhs).
swap(*
this);
372 bool tmp2 = counting;
386 return a.
get() == b.
get();
391 return a.
get() != b.
get();
417 #endif // XAPIAN_INCLUDED_INTRUSIVE_PTR_H The Xapian namespace contains public interfaces for the Xapian library.
bool operator==(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b)
intrusive_ptr & operator=(T *rhs)
intrusive_base()
Construct with no references.
opt_intrusive_ptr(opt_intrusive_ptr< U > const &rhs)
unsigned _refs
Reference count.
intrusive_ptr(intrusive_ptr< U > const &rhs)
void operator=(const intrusive_base &)
Prevent assignment.
opt_intrusive_ptr & operator=(opt_intrusive_ptr const &rhs)
opt_intrusive_base & operator=(const opt_intrusive_base &)
#define XAPIAN_VISIBILITY_DEFAULT
opt_intrusive_ptr & operator=(T *rhs)
opt_intrusive_ptr this_type
Define XAPIAN_VISIBILITY_* macros.
opt_intrusive_base(const opt_intrusive_base &)
void swap(opt_intrusive_ptr &rhs)
opt_intrusive_ptr(opt_intrusive_ptr const &rhs)
Base class for objects managed by intrusive_ptr.
Base class for objects managed by opt_intrusive_ptr.
virtual ~opt_intrusive_base()
unsigned _refs
Reference count.
opt_intrusive_base()
Construct object which is initially not reference counted.
void swap(intrusive_ptr &rhs)
intrusive_ptr & operator=(intrusive_ptr const &rhs)
A smart pointer that optionally uses intrusive reference counting.
A smart pointer that uses intrusive reference counting.
intrusive_ptr(intrusive_ptr const &rhs)
bool operator!=(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b)
void release() const
Start reference counting.