[C++-sig] boost.python: private copy constructor problem

Mihail Konstantinov kmihail at rocketmail.com
Tue Dec 2 15:25:47 CET 2008


> try use boost::noncopyable to B or implemente a copy constructor in B

> without call A copy contructor.

Thank you. This works:
BOOST_PYTHON_MODULE(boost_ext)
{
    class_<A, boost::noncopyable> a("A",init<>());
    class_<B, bases<A>, boost::noncopyable >("B",init<>());
}

One more question about the syntax. You cited http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/class.html#class_-spec which specifies the syntax as "class_<T,Bases,HeldType,NonCopyable>" so that I thought I have to include all 4 template arguments. But when I used instead of the above (working!) solution:
    class_<A, bases<>, A, boost::noncopyable> a("A",init<>());
    class_<B, bases<A>, B, boost::noncopyable >("B",init<>());
I get the error:
>/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp:159: error: no matching function for call to
>‘B::B(PyObject*&)’
>boost.cpp:13: note: candidates are: B::B()
>boost.cpp:11: note:                 B::B(const B&)

Why does the abbreviated template argument list work, and why not the complete argument list?

Thank you
Mihail



      



More information about the Cplusplus-sig mailing list