[C++-sig] boost python and boost/thread.hpp

Jim Bosch talljimbo at gmail.com
Sun Feb 12 19:56:12 CET 2012


On 02/12/2012 01:34 PM, Guillaume Carbonneau wrote:
> Hi,
>
> I'm having compilation errors as soon as I give my classes member
> variables that come from the boost thread library.
> Wrapping those in shared_ptr seems to work.
>
> Any idea why? Is there a special wrapping directive I should give it to?
>

The problem is that boost::condition_variable doesn't have a copy 
constructor.  When you declare a class with Boost.Python, it assumes it 
can be returned by value (which requires a copy constructor).  The 
boost::condition_variable data member prevents the compiler from 
generating an implicit copy constructor.

You can solve this by instead using:

class_<Hello,boost::noncopyable>("Hello");

That tells Boost.Python not to assume this class can be returned by 
value.  If it makes sense to define an explicit copy constructor for 
your class, that will work too.

Jim


More information about the Cplusplus-sig mailing list