[C++-sig] Re: wrapping class X with private constructor X::X(const X&)

David Abrahams dave at boost-consulting.com
Thu Mar 4 22:33:50 CET 2004

Pearu Peterson <pearu at cens.ioc.ee> writes:

> I am trying to wrap a library class that is special in the sense
> that its constructor is specified as private and this causes
> compilation to fail. Is it true that boost.python tries
> to use X::X(const X&) internally? 

Yes; it has to figure out how to return Xs from functions, should you
wrap such a function.

> Is is possible to avoid it?

yes (see below).

> (I tried to use no_init and init<>() with no success.)
> Thanks,
> Pearu
> Details
> -------
> GCC: 3.3.3
> Here is a fragment of my boost.python wrapper:
>   class_<agg::matrix<agg::int8u> >("matrix");
add ", boost::noncopyable" -------^

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list