[C++-sig] How to manage smart pointer as return value of a factory?

Julien swell at netcourrier.com
Thu Feb 16 15:26:06 CET 2006


You are absolutely right i am using msvc and don't generate the RTTI 
informations. If i do the change to allow RTTI and  it works perfectly.
Now i have the last pb of my factory , in fact i have several create method in 
my factory let say

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

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(FactY_create, create, 2, 2)


BOOST_PYTHON_MODULE(hello)
{
	class_<FactY>("FactY",no_init)
		.def("create",&FactY::create,FactY_create(args("x","y")) )
		.staticmethod("create")
	;
}

I can't succeed to compile this, but i saw many way to solve member 
overloading (docs, mailing list, tutorial ) that i am lost in which is the 
correct method.
I have this message error :
C2780: 'boost::python::class_<W>::self &boost::python::class_<W>::def(const 
char *,Fn,const A1 &,const A2 &,const A3 &)' : expects 5 arguments - 3 provided
        with
        [
            W=FactY
        ]





More information about the Cplusplus-sig mailing list