boost::python: compilation fails because copy constructor is private

c++, python

Solution

I found it. i have to specify boost::noncopyable:

BOOST_PYTHON_MODULE(Foo)
{   
  class_<Foo, boost::noncopyable>("Foo", init<const char *>())
  ;
}

Problem

i use boost::python to wrap a C++ class. This class does not allow copy constructors, but the python module always wants to create one. The C++ class looks like this (simplified) ``` class Foo { public: Foo(const char *name); // constructor private: ByteArray m_bytearray; }; ``` The ByteArray class is inherited from boost::noncopyable, therefore Foo does not have copy constructors. Here's the Python module stub: ``` BOOST_PYTHON_MODULE(Foo) { class_<Foo>("Foo", init<const char *>()) ; } ``` When compiling the boost::python module, i get errors that a copy constructor for Foo cannot be created because ByteArray inherits from boost::noncopyable. How can i disable copy constructors in my python module? Thanks Christoph

Original source