[C++-sig] Re: Type Exception of type Argument Error

Brian Hall bhall at gamers-fix.com
Mon Jul 12 06:39:28 CEST 2004

That fixed it all up!  I've converted all my references and whatnot over to
using shared_ptr (way safer I agree) and I'm in business!  Works great and
much easier than the stuff I was going through! 

Thanks!  I'll keep everyone in the loop on how the rest of it goes!


-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of David Abrahams
Sent: Sunday, July 11, 2004 6:15 PM
To: c++-sig at python.org
Subject: [C++-sig] Re: Type Exception of type Argument Error

"Brian Hall" <bhall at gamers-fix.com> writes:

> 		// create new instance of object
> 		object newInstance = typeObj(*b);

		object newInstance = typeObj(boost::ref(*b));


		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

C++-sig mailing list
C++-sig at python.org

More information about the Cplusplus-sig mailing list