[C++-sig] using object constructor

David Abrahams david.abrahams at rcn.com
Fri Jun 21 20:06:11 CEST 2002


From: "Dave Hawkes" <daveh at cadlink.com>

> If we want to start wrapping a significant number of functions to return
> objects is this the best way to do it as it seems inherently unsafe as
> almost any type of pointer return could be cast in this way.

It's an implementation detail, not for public consumption.

> Is there any reason why a new template class like borrowed but called
> (possibly) new_pyobject was not used?

It adds complication and overhead in debug builds.

> That way we could get some additional
> type safety from using new_pyobject<PyObject*> in the constructor
definition
> akin to the existing borrowed/null_ok definitions.

Yeah, technically you're right. I am not very happy about all the code that
gets generated to handle borrowed, etc. right now though. I'm ambivalent
about making the change, but would be willing to look at a patch.

-Dave







More information about the Cplusplus-sig mailing list