Boost logo

Boost Users :

From: Arun Dharankar (ADharankar_at_[hidden])
Date: 2006-03-04 22:19:56


Hello,

The type of shared pointer I have in mind is boost::shared_ptr. Is there
some way I can extend/modify (short of re-writing) cleanly its functionality
such that when its reference counter becomes zero, a method in the
actual pointer's class is called instead of that class's destructor
being called?

Consider the following snippet to allow me to explain:

  class A {
    public:
      A() { }
     ~A() { }
     void deleteA() { }
  };

  boost::shared_ptr<A> a(new A);
  a.reset();

In this example, when a.reset() is called A's I want the deleteA() method to
be called instead of the destructor for A. It would then be up to
deleteA() to
decide if/when to cause the delete of the real object.

Best regards,
-Arun.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net