[C++-sig] HeldType - class has only non trivial constructor

Roman Yakovenko romany at actimize.com
Thu Aug 28 20:00:49 CEST 2003

Hi. After a few hours of fight I decided - I need help.
Sorry for long posting. Reference to previous thread or solution
would be great. In two words the problem is simple. I have based and 
derived classes with only non trivial constructor( for factory method ).
Base class is pure virtual so I have to wrape it and Derived class.
And after I do this I've got a compilation error.

Here is the code ( after all my English is not my native language ):

struct K{};

struct MyBase { 
    MyBase( const K& _k) : {} 
    virtual ~MyBase(){}

struct MyDerived : public MyBase{ 
    MyDerived( const K& k) : MyBase(k) {}    

struct MyBase_Wrapper: MyBase
    MyBase_Wrapper(PyObject* self_, const K& p0) : MyBase(p0), self(self_) {}   
    PyObject* self;

struct MyDerived_Wrapper : MyDerived
    MyDerived_Wrapper(PyObject* self_, const K& p0) : MyDerived(p0), self(self_) {}
    PyObject* self;

   class_< K >( "K" )();
   class_< MyBase, bases<>, MyBase_Wrapper, boost::noncopyable >("Base", init< const K& >() );
   class_< MyDerived, bases< MyBase > , MyDerived_Wrapper >("Derived", init< const K& >() );

As you may guess I can't compile this code ( MSVC 6.0 SP5 ). 
The error is: cannot convert parameter 2 from 'const struct MyDerived' to 'const struct K &'
The struct make_instance is instantiated (in case MyDerived ) with arguments 
MyDerived and MyDerived_Wrapper. I just do know what I have to do in order
write the wrapper. Some hint ?

Thanks for the help.


More information about the Cplusplus-sig mailing list