Problem with smart pointers

S

swell

Hello,
I use the Boost.Python lib for a couple of weeks now and i am
facing a pb.
To sum up i have a small hierarchy of objects and have a factory to
build concrete object. The pb is i think aroud the auto_ptr object that
is not correctly managed by my code ( i use version 1.33 )
I think that the solution is obvious but i can't sort it out. If you
could have a look at this small test


struct X
{
virtual int fun1() = 0;
int fun2() { return 2;}
virtual int fun3() { return -1; }
};

struct Y : public X
{
int fun1() {return 1;}
virtual fun3() { return 3; }
};

struct FactY
{
static std:auto_ptr<X> create() { return std:auto_ptr<X>(new Y());}
};


BOOST_PYTHON_MODULE(hello)
{
class_<X, boost::noncopyable >("X",no_init);
class_<Y, boost::python::bases<X> >("Y")
.def("fun1",&Y::fun1)
.def("fun2",&Y::fun2)
.def("fun3",&Y::fun3)
;

class_<FactY>("FactY",no_init)
.def("create",&FactY::create)
.staticmethod("create")
;
}

Many Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top