[C++-sig] Re: Type Exception of type Argument Error
David Abrahams
dave at boost-consulting.com
Mon Jul 12 02:15:00 CEST 2004
"Brian Hall" <bhall at gamers-fix.com> writes:
> // create new instance of object
> object newInstance = typeObj(*b);
object newInstance = typeObj(boost::ref(*b));
or
object newInstance = typeObj(ptr(b));
Will get you over this particular hurdle.
But you have major ownership issues. Your B object ought to be
created within a Python object
pyB = class_<B>("B", init<float>())
.add_property("value", &B::Value, &B::SetValue)
;
...
object b = pyB(10);
or held by a shared_ptr:
boost::shared_ptr<B> b(new B(10));
Your A ought to hold a shared_ptr<B>, and you shouldn't use
return_internal_reference on GetB: that's only for when the return
value is a subobject of an argument to the method (self in this case).
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list