Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-03-31 23:48:50

----- Original Message -----
From: "David Abrahams" <abrahams_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, March 31, 2001 5:32 PM
Subject: Re: [boost] creating a BPL instance from an existing C++ object.

> This has come up several times. There is a limitation in Boost.Python
> makes trying to do what you want dangerous at best. I posted a proposed
> solution at, but given
> deafening silence I got as a response, I just keep directing people at the
> section titled "If you can't (afford to) copy the referent, or the pointer
> is non-const" on this page:
> I would happily make the proposed change to Boost.Python, but would like
> hear /something/ from users before undertaking any redesign.

There are cases where 'boost::python::owned_by_arg' is inadequate. For
example, consider the following:

// Singleton pattern:
C& get_the_C()
  static C the_C;
  return the_C;

// Object not passed to Python through return value:
void outer::f() {
  boost::python::callback<void>::call_method(this->self, f,

// Object retrieved from Python, then passed back through a different
class C {
  set_d(D *d) { this->d = d; }
  D* get_d() const { return this->d; }
  D *d;

In conclusion, 'owned_by_arg' would be nice (though by no means vital for me
personally), but a more general solution would be better.

Rainer Deyke (root_at_[hidden])
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at, gregod at, cpdaniel at, john at