copy construktor problem by extending python with c++ using boost python lib

Alex Martelli aleaxit at yahoo.com
Mon Apr 23 04:15:13 EDT 2001


"stefan kusch" <stefan2k1de at yahoo.de> wrote in message
news:3ae3d8a9.3655125 at news.t-online.de...
    [snip]
>     class mein::CObRegistry> >(class
> boost::python::detail::extension_instance *,
>                                class mein::CObRegistry)' :
>     Conversion of parameters 2 from 'const class mein::CObRegistry' in
>     'class mein::CObRegistry' not possible

Looks right: you cannot convert (copy) a const object in your
sample code below.

>     No copy constructor for class 'mein::CObRegistry' available

Exactly.  No copy constructor (for a const object) is available
in your code.  The key sample C++ portion is:

> class A
> {
> A();
> A(A &a);

This latter line says you can construct an A from a *NON-CONST* A.

There is apparently no way to construct an A from a *CONST* A, as
in the normal C++ idiom for copy construction, A(const A& a).

If you really have an A with very complex semantics so that a
non-const object can't be copied, that will require QUITE some
handling indeed.  If you want A's to be canonical, then they
will need a normal copy constructor.


Alex






More information about the Python-list mailing list