[C++-sig] [pybindgen] references?

Hans Meine meine at informatik.uni-hamburg.de
Tue Nov 4 10:19:16 CET 2008


On Tuesday 04 November 2008 01:18:47 Alan Baljeu wrote:
> void baz(foo &x);
>
> If I have a foo, I call baz with it, foo's contents may change but it's
> still the same object.  I don't see an issue here, unless foo is a smart
> pointer type.

Sometimes, baz might store the reference (admittedly, that's not very good 
design, except for some register_xxx functions, but I'd use pointers then 
anyway), and when the foo is destroyed, you have a dangling reference.  In 
boost::python, this can be prevented, by binding the lifetime of foo to some 
other objects (where baz stores the reference).

Greetings,
  Hans


More information about the Cplusplus-sig mailing list