[C++-sig] X_wrap(PyObject* self, int v) FAQ example won't compile

Christophe Gratin christophe.gratin at adcis.net
Fri Mar 10 19:25:40 CET 2006


I tried the following code from the boost python FAQ, 
(http://www.boost.org/libs/python/doc/v2/faq.html) but it doesn't 
compile (MS Visual C++ 2005).
The error message is dumped below.

class X { public: X(int) {}; virtual ~X(){}; };

struct X_wrap : X
{
    X_wrap(PyObject* self, int v) : self(self), X(v) {}
    PyObject* self;
};

BOOST_PYTHON_MODULE(Test)
{
    {
        class_<X,X_wrap>("X", init<int>());
    }
}



[....]\boost\boost\python\object\value_holder.hpp(160) : error C2664: 
'X_wrap::X_wrap(PyObject *,int)' : cannot convert parameter 2 from 
'const X' to 'int'
        No user-defined-conversion operator available that can perform 
this conversion, or the operator cannot be called
        [....]\boost\boost\python\object\make_instance.hpp(68) : see 
reference to function template instantiation 
'boost::python::objects::value_holder_back_reference<Value,Held>::value_holder_back_reference<boost::reference_wrapper<T>>(PyObject 
*,A0)' being compiled
        with
        [
            Value=X,
            Held=X_wrap,
            T=const X,
            A0=boost::reference_wrapper<const X>
        ]
        [....]\boost\boost\python\object\make_instance.hpp(67) : while 
compiling class template member function 
'boost::python::objects::value_holder_back_reference<Value,Held> 
*boost::python::objects::make_instance<T,Holder>::construct(void 
*,PyObject *,boost::reference_wrapper<const T>)'
        with
        [
            Value=X,
            Held=X_wrap,
            T=X,
            
Holder=boost::python::objects::value_holder_back_reference<X,X_wrap>
        ]
        [....]\boost\boost\python\object\class_wrapper.hpp(26) : see 
reference to class template instantiation 
'boost::python::objects::make_instance<T,Holder>' being compiled
        with
        [
            T=X,
            
Holder=boost::python::objects::value_holder_back_reference<X,X_wrap>
        ]
        [....]\boost\boost\python\object\class_wrapper.hpp(25) : while 
compiling class template member function 'PyObject 
*boost::python::objects::class_cref_wrapper<Src,MakeInstance>::convert(const 
Src &)'
        with
        [
            Src=X,
            
MakeInstance=boost::python::objects::make_instance<X,boost::python::objects::value_holder_back_reference<X,X_wrap>>
        ]
        [....]\boost\boost\python\object\class_metadata.hpp(260) : see 
reference to class template instantiation 
'boost::python::objects::class_cref_wrapper<Src,MakeInstance>' being 
compiled
        with
        [
            Src=X,
            
MakeInstance=boost::python::objects::make_instance<X,boost::python::objects::value_holder_back_reference<X,X_wrap>>
        ]
        [....]\boost\boost\python\object\class_metadata.hpp(229) : see 
reference to function template instantiation 'void 
boost::python::objects::class_metadata<T,X1,X2,X3>::maybe_register_class_to_python<T2>(T2 
*,boost::mpl::false_)' being compiled
        with
        [
            T=X,
            X1=X_wrap,
            X2=boost::python::detail::not_specified,
            X3=boost::python::detail::not_specified,
            T2=X
        ]
        [....]\boost\boost\python\object\class_metadata.hpp(219) : see 
reference to function template instantiation 'void 
boost::python::objects::class_metadata<T,X1,X2,X3>::register_aux2<T,boost::integral_constant<bool,true>>(T2 
*,Callback)' being compiled
        with
        [
            T=X,
            X1=X_wrap,
            X2=boost::python::detail::not_specified,
            X3=boost::python::detail::not_specified,
            T2=X,
            Callback=boost::integral_constant<bool,true>
        ]
        [....]\boost\boost\python\object\class_metadata.hpp(217) : while 
compiling class template member function 'void 
boost::python::objects::class_metadata<T,X1,X2,X3>::register_aux(void *)'
        with
        [
            T=X,
            X1=X_wrap,
            X2=boost::python::detail::not_specified,
            X3=boost::python::detail::not_specified
        ]
        [....]\boost\boost\python\class.hpp(174) : see reference to 
class template instantiation 
'boost::python::objects::class_metadata<T,X1,X2,X3>' being compiled
        with
        [
            T=X,
            X1=X_wrap,
            X2=boost::python::detail::not_specified,
            X3=boost::python::detail::not_specified
        ]
        [....]\boost\boost\python\class.hpp(205) : see reference to 
class template instantiation 'boost::python::class_<W,X1>::id_vector' 
being compiled
        with
        [
            W=X,
            X1=X_wrap
        ]
        [....]\pythonTest.cpp(244) : see reference to function template 
instantiation 
'boost::python::class_<W,X1>::class_<boost::python::init<T0>>(const char 
*,const boost::python::init_base<DerivedT> &)' being compiled
        with
        [
            W=X,
            X1=X_wrap,
            T0=int,
            DerivedT=boost::python::init<int>
        ]



More information about the Cplusplus-sig mailing list