[C++-sig] Boost Python wrapper<> causing a compile error C2664 in vc++ 8.0

Matthew Scouten matthew.scouten at gmail.com
Fri Sep 7 18:43:21 CEST 2007


I am trying to wrap a class with virtual functions in c++, to be over
loaded in Python, and called from c++.

I have been working up to full functionality gradually but I have hit
a road block.

 My code (trimmed to only relevant parts, with the identifiers changed
to protect the guilty):

 class CProofOfConcept {
public:
                int x;
                CProofOfConcept(void);
                virtual std::string reality(void) const;
                std::string ProofOfCallback();
private:
                float y;
};

CProofOfConcept::CProofOfConcept()
{
                std::cout << "Creation of Information!" <<std::endl;
}

std::string CProofOfConcept::reality(void) const
{
                return "this is the real thing, baby!!";
}

std::string CProofOfConcept::ProofOfCallback()
{
                return this->reality();
}

class CProofOfConceptWrapper: public CProofOfConcept, public
wrapper<CProofOfConcept>
{

};

BOOST_PYTHON_MODULE(poc)
{
                class_<CProofOfConceptWrapper>("CPOC")
                                .def("reality",
&CProofOfConceptWrapper::reality)
                                .def_readwrite("x", &CProofOfConceptWrapper::x)
                                .def("ProofOfCallback" ,
&CProofOfConceptWrapper::ProofOfCallback)
                                ;

}

And my error:

boost/python/object/value_holder.hpp(133) : error C2664:
'CProofOfConceptWrapper::CProofOfConceptWrapper(const
CProofOfConceptWrapper &)' : cannot convert parameter 1 from 'const
CProofOfConcept' to 'const CProofOfConceptWrapper &'

if I change:

class CProofOfConceptWrapper: public CProofOfConcept, public
wrapper<CProofOfConcept>

to :
                class CProofOfConceptWrapper: public CProofOfConcept
//, public wrapper<CProofOfConcept>

 it compiles just fine.

In case it is relevant:
Boost version: 1.32.0
Python version: 2.5
Compiler: vc++ 8.0

If this is a dumb question, apologies in advance. I just learned
Python a few weeks ago, my C++ is rusty, and all I know about
boost::python is what I can find in online docs.

Thanks in advance for any help you can give me.



More information about the Cplusplus-sig mailing list