[C++-sig] std::auto_ptr<> in constructor
Tomasz Mikolajczyk
tmmikolajczyk at gmail.com
Thu Apr 15 00:08:02 CEST 2010
Hi,
I'm a new user of boost::python art. I started to play a bit with the
code and the py++ generator and encountered difficulties with the
std::auto_ptr in constructor.
The following code:
class A
{
public:
A(int value) : m_value(value) {}
private:
int m_value;
};
class B
{
public:
B(int value, std::auto_ptr<A> a) : m_value(value), m_a(a.release()) {}
private:
int m_value;
std::auto_ptr<A> m_a;
};
has been bound to the following code:
BOOST_PYTHON_MODULE(pyplusplus)
{
{ //::A
typedef bp::class_< A, boost::noncopyable > A_exposer_t;
A_exposer_t A_exposer = A_exposer_t( "A", bp::init< int >((
bp::arg("value") )) );
bp::scope A_scope( A_exposer );
bp::implicitly_convertible< int, A >();
bp::register_ptr_to_python< std::auto_ptr< A > >();
}
bp::class_< B, boost::noncopyable >( "B", bp::init< int,
std::auto_ptr< A > >(( bp::arg("value"), bp::arg("a") )) );
}
Unfortunately, the generated code compiles with the following error:
/usr/local/boost_1_42_0/include/boost/python/object/value_holder.hpp:137:
error: no matching function for call to
‘std::auto_ptr<A>::auto_ptr(const std::auto_ptr<A>&)’
I understand the error but I don't know what to do to avoid it.
Regeards,
Tomek
More information about the Cplusplus-sig
mailing list