Boost C++ Libraries

PrevUpHomeNext

Class intrusive_ref_counter

boost::log::intrusive_ref_counter — A reference counter base class.

Synopsis

// In header: <boost/log/utility/intrusive_ref_counter.hpp>


class intrusive_ref_counter {
public:
  // construct/copy/destruct
  intrusive_ref_counter();
  intrusive_ref_counter(intrusive_ref_counter const &);
  intrusive_ref_counter& operator=(intrusive_ref_counter const &);
  ~intrusive_ref_counter();

  // public member functions
  unsigned long use_count() const;
};

Description

This base class can be used with user-defined classes to add support for intrusive_ptr. The class contains a thread-safe reference counter and a virtual destructor, which makes the derived class polymorphic. Upon releasing the last intrusive_ptr referencing the object derived from the intrusive_ref_counter class, operator delete is automatically called on the pointer to the object.

intrusive_ref_counter public construct/copy/destruct

  1. intrusive_ref_counter();

    Default constructor

    Postconditions:

    use_count() == 0

  2. intrusive_ref_counter(intrusive_ref_counter const &);

    Copy constructor

    Postconditions:

    use_count() == 0

  3. intrusive_ref_counter& operator=(intrusive_ref_counter const &);

    Assignment

    Postconditions:

    The reference counter is not modified after assignment

  4. ~intrusive_ref_counter();

    Virtual destructor

intrusive_ref_counter public member functions

  1. unsigned long use_count() const;

    Returns:

    The reference counter


PrevUpHomeNext