Provided by: librheolef-dev_5.93-2_i386 bug


       occurence, smart_pointer - memory management


        Here is a convenient way to implement a true copy semantc,
        by using shallow copies and reference counting, in order to
        minimise memory copies.
        This concept is generally related to the smart pointer
        method for managing memory.

        The true semantic copy is defined as follows: if an object
        A is assigned to
        B, such as A = B, every further modification on A or B
        does not modify the other.


       template <class T>
       class smart_pointer {

       // allocators:

               smart_pointer (T* p = 0);
               smart_pointer (const smart_pointer&);
               ~smart_pointer ();
               smart_pointer& operator= (const smart_pointer&);

       // accessors:

               const T* pointer    () const;
               const T& data       () const;
               const T* operator-> () const;
               const T& operator*  () const;

       // modifiers:

               T* pointer ();
               T* operator-> ();
               T& data ();
               T& operator* ();

       // implementation:

               struct counter {
                       T*  _p;
                       int _n;
                       counter (T* p = 0);
                       ~counter ();
                       int operator++ ();
                       int operator-- ();
               counter *_count;