std::auto_ptr<> in constructor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

std::auto_ptr<> in constructor

Tomasz Mikolajczyk
Hi,

I'm a new user of boost::python art. I started to play a bit with the
code and the py++ code 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 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. Please help.

Regeards,
Tomek


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Loading...