[C++-sig] Overloaded Member functions

David Abrahams dave at boost-consulting.com
Fri Feb 17 15:11:41 CET 2006


Julien <swell at netcourrier.com> writes:

> Hi ,
>    Still playing around the boost python wrapper/generator. 
>
> i have this structure that i want to wrap :
>
> struct X
> {};
>
> struct FactoryX
> {
>   static std::auto_ptr<X> create() 	 {return std::auto_ptr<X>( new X() );}
>   static std::auto_ptr<X> create(int) 	 {return std::auto_ptr<X>( new X() );}
>   static std::auto_ptr<X> create(double) {return std::auto_ptr<X>( new X() );}
> };
>
> i try this but can't get it work!
>
> std::auto_ptr<X> (FactoryX::*create1)() 	= &FactoryX::create;
> std::auto_ptr<X> (FactoryX::*create2)(int) 	= &FactoryX::create;
> std::auto_ptr<X> (FactoryX::*create3)(double) 	= &FactoryX::create;

These are only member functions in scope, but not in type, since
they're static.  Just use ordinary function pointers, e.g.

 std::auto_ptr<X> (*create3)(double) = &FactoryX::create;

HTH,
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list