Home | Libraries | People | FAQ | More |
boost::interprocess::intrusive_ptr
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp> template<typename T, typename VoidPointer> class intrusive_ptr { public: // types typedef boost::intrusive::pointer_traits< VoidPointer >::template rebind_pointer< T >::type pointer; // Provides the type of the internal stored pointer. typedef T element_type; // Provides the type of the stored pointer. // construct/copy/destruct intrusive_ptr() noexcept; intrusive_ptr(const pointer &, bool = true) noexcept; intrusive_ptr(intrusive_ptr const &) noexcept; intrusive_ptr(intrusive_ptr &&) noexcept; template<typename U> intrusive_ptr(intrusive_ptr< U, VP > const &) noexcept; intrusive_ptr & operator=(BOOST_COPY_ASSIGN_REF(intrusive_ptr)) noexcept; intrusive_ptr & operator=(intrusive_ptr &&) noexcept; template<typename U> intrusive_ptr & operator=(intrusive_ptr< U, VP > const &) noexcept; intrusive_ptr & operator=(pointer) noexcept; ~intrusive_ptr(); // public member functions void reset() noexcept; pointer & get() noexcept; const pointer & get() const noexcept; T & operator*() const noexcept; const pointer & operator->() const noexcept; pointer & operator->() noexcept; operator unspecified_bool_type() const noexcept; bool operator!() const noexcept; void swap(intrusive_ptr &) noexcept; };
The intrusive_ptr class template stores a pointer to an object with an embedded reference count. intrusive_ptr is parameterized on T (the type of the object pointed to) and VoidPointer(a void pointer type that defines the type of pointer that intrusive_ptr will store). intrusive_ptr<T, void *> defines a class with a T* member whereas intrusive_ptr<T, offset_ptr<void> > defines a class with a offset_ptr<T> member. Relies on unqualified calls to:
void intrusive_ptr_add_ref(T * p) BOOST_NOEXCEPT; void intrusive_ptr_release(T * p) BOOST_NOEXCEPT;
with (p != 0)
The object is responsible for destroying itself.
intrusive_ptr
public
construct/copy/destructintrusive_ptr() noexcept;
Constructor. Initializes internal pointer to 0. Does not throw
intrusive_ptr(const pointer & p, bool add_ref = true) noexcept;
Constructor. Copies pointer and if "p" is not zero and "add_ref" is true calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
intrusive_ptr(intrusive_ptr const & rhs) noexcept;
Copy constructor. Copies the internal pointer and if "p" is not zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
intrusive_ptr(intrusive_ptr && rhs) noexcept;Move constructor. Moves the internal pointer. Does not throw.
template<typename U> intrusive_ptr(intrusive_ptr< U, VP > const & rhs) noexcept;
Constructor from related. Copies the internal pointer and if "p" is not zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
intrusive_ptr & operator=(BOOST_COPY_ASSIGN_REF(intrusive_ptr) rhs) noexcept;
Assignment operator. Equivalent to intrusive_ptr(r).swap(*this). Does not throw
intrusive_ptr & operator=(intrusive_ptr && rhs) noexcept;
Move Assignment operator Does not throw
template<typename U> intrusive_ptr & operator=(intrusive_ptr< U, VP > const & rhs) noexcept;
Assignment from related. Equivalent to intrusive_ptr(r).swap(*this). Does not throw
intrusive_ptr & operator=(pointer rhs) noexcept;
Assignment from pointer. Equivalent to intrusive_ptr(r).swap(*this). Does not throw
~intrusive_ptr();Destructor. Calls reset(). Does not throw.
intrusive_ptr
public member functionsvoid reset() noexcept;
Release internal pointer and set it to 0. If internal pointer is not 0, calls intrusive_ptr_release(to_raw_pointer(m_ptr)). Does not throw
pointer & get() noexcept;
Returns a reference to the internal pointer. Does not throw
const pointer & get() const noexcept;
Returns a reference to the internal pointer. Does not throw
T & operator*() const noexcept;
Returns *get(). Does not throw
const pointer & operator->() const noexcept;
Returns *get(). Does not throw
pointer & operator->() noexcept;
Returns get(). Does not throw
operator unspecified_bool_type() const noexcept;
Conversion to boolean. Does not throw
bool operator!() const noexcept;
Not operator. Does not throw
void swap(intrusive_ptr & rhs) noexcept;
Exchanges the contents of the two smart pointers. Does not throw