[C++-sig] manage_new_object using release() instead of delete

Eric wstwej03 at sneakemail.com
Tue Apr 13 17:01:34 CEST 2004


Hi all,



I am new to Boost.Python, but so far have been extremely impressed. I was wondering if there was a version of the manage_new_object return policy that called a release() function on an interface rather than calling delete?



I am trying to wrap a chunk of code that works like this:



class Interface {

public:

  virtual void doSomething() = 0;

  virtual void release() = 0;

protected:

  virtual ~Interface() {}

};



Interface *

SomeFactory( ... );



Now, if Interface was a normal data struct, I'd just use manage_new_object as the policy for SomeFactory, but that wouldn't work here because the destructor is protected. Is there some way to have the release function called at the end of the Interface pointer's life in python? And is it further possible to have the release() function not be callable from python (to protect against double-deletes)? Thanks!




More information about the Cplusplus-sig mailing list