I am trying to return a shared pointer to a class Foo and then 
test the results in python for equality, but they always seem to fail.
I've created the following two trivial classes: 

class Foo : public boost::noncopyable
{
}; 

typedef boost::shared_ptr<Foo> pFoo_t; 

class FooCreator
{
public:
  pFoo_t createFoo() {
    pFoo_t ft(new Foo); 
    intfoo = ft; 
    return ft; 
  }
  
  pFoo_t getFoo() {
    return intfoo; 
  }

  pFoo_t intfoo; 

}; 


That I expose with boost::python via: 

  class_<Foo, pFoo_t, boost::noncopyable>("Foo", no_init); 
  
  class_<FooCreator>("FooCreator")
    .def("createFoo", &FooCreator::createFoo)
    .def("getFoo", &FooCreator::getFoo); 

Yet the following assert fails:

fc = FooCreator()

foo = fc.createFoo()
foo2 = fc.getFoo()

assert_equal(foo, foo2)

The above assert fails. I've tried using the newest boost::python, I've
looked through the mailing list archives and even asked on IRC, but I
still can't figure out which part of this process I'm doing incorrectly.
I've spent about 20 hours reducing my problem to this test case, and am
really stumped. 

        ...Eric


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to