[C++-sig] X_wrap(PyObject* self, int v) FAQ example won't compile
David Abrahams
dave at boost-consulting.com
Mon Mar 13 07:40:21 CET 2006
Christophe Gratin <christophe.gratin at adcis.net> writes:
> 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>());
> }
> }
The error comes from trying to expose the copy ctor for X and not
finding an appropriate X_wrap ctor containing a PyObject* as its first
argument. You can fix it by adding boost::noncopyable to the template
argument list for class_
class_<X,X_wrap,boost::noncopyable>("X", init<int>());
Sorry for the hassle. FAQ updated.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list