[C++-sig] intrusive pointer comparison in python

Gross, Ashley agross at irobot.com
Wed Oct 4 21:42:14 CEST 2006


Here's a better example:

class foo;
typedef boost::intrusive_ptr<foo> fooHandle;

// personal refcounting implementation
class foo: public reference_counted {}; 
};

class foocontainer {
public:
	foocontainer():fooobj(foo::getfoo()) {}
	fooHandle getfoo() {return fooobj;}
private:
	fooHandle fooobj;
};

BOOST_PYTHON_MODULE(test_intrusive) {
	class_<foo,fooHandle>("foo");
	class_<foocontainer>("foocontainer")
		.def("getfoo",&foocontainer::getfoo);
}

Now if I go into python shell:
>> x=foocontainer()
>> test1=x.getfoo()
>> test2=x.getfoo()
>> test1==test2
False

> -----Original Message-----
> From: Hans Meine [mailto:meine at informatik.uni-hamburg.de]
> Sent: Wednesday, October 04, 2006 1:03 PM
> To: Gross, Ashley
> Subject: Re: [C++-sig] intrusive pointer comparison in python
> 
> On Wednesday, 04. October 2006 18:43, Gross, Ashley wrote:
> > intrusive_ptr1=foo()
> >
> > intrusive_ptr2=intrusive_ptr1
> >
> > intrusive_ptr1==intrusive_ptr2
> 
> AFAIK, this should work (it does out-of-the-box with BPL for me).
> 
> --
> Ciao, /  /
>      /--/
>     /  / ANS



More information about the Cplusplus-sig mailing list