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

Pearu Peterson pearu at cens.ioc.ee
Thu Mar 4 22:16:58 CET 2004


Hi,

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? Is is possible to avoid it?
(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");
  //where `int8u` is typedef `unsigned char`

Here's the definition of agg::matrix:

template<class T> class matrix
{
    public:
        matrix();
        matrix(T* buf, unsigned width, unsigned height, int stride);

    <snip>

    private:
        matrix(const matrix&);

    <snip>

}

and here follows the error message:

bpl_src/rendering_buffer.cpp: In function `void
export_rendering_buffer()':
bpl_src/rendering_buffer.cpp:8: warning: unused variable `char 
   rendering_buffer_doc[26]'
agg2/include/agg_matrix.h: In constructor `
   boost::python::objects::value_holder<Value>::value_holder(PyObject*,
A0) 
   [with A0 = boost::reference_wrapper<const agg::matrix<int8u> >, Value = 
   agg::matrix<int8u>]':
boost_1_31_0/boost/python/object/make_instance.hpp:69:   instantiated from
`static Holder* boost::python::objects::make_instance<T,
Holder>::construct(void*, PyObject*, boost::reference_wrapper<const
T>) [with T = agg::matrix<int8u>, Holder =
boost::python::objects::value_holder<agg::matrix<int8u> >]'
boost_1_31_0/boost/python/object/make_instance.hpp:43:   instantiated from
`static PyObject* boost::python::objects::make_instance_impl<T, Holder,
Derived>::execute(Arg&) [with Arg = const boost::reference_wrapper<const
agg::matrix<int8u> >, T = agg::matrix<int8u>, Holder =
boost::python::objects::value_holder<agg::matrix<int8u> >, Derived =
boost::python::objects::make_instance<agg::matrix<int8u>,
boost::python::objects::value_holder<agg::matrix<int8u> > >]'
boost_1_31_0/boost/python/object/class_wrapper.hpp:27:   instantiated from
`static PyObject* boost::python::objects::class_cref_wrapper<Src,
MakeInstance>::convert(const Src&) [with Src = agg::matrix<int8u>,
MakeInstance = boost::python::objects::make_instance<agg::matrix<int8u>,
boost::python::objects::value_holder<agg::matrix<int8u> > >]'
boost_1_31_0/boost/python/converter/as_to_python_function.hpp:28:   instantiated
from `static PyObject* boost::python::converter::as_to_python_function<T,
ToPython>::convert(const void*) [with T = agg::matrix<int8u>, ToPython =
boost::python::objects::class_cref_wrapper<agg::matrix<int8u>,
boost::python::objects::make_instance<agg::matrix<int8u>,
boost::python::objects::value_holder<agg::matrix<int8u> > > >]'
boost_1_31_0/boost/python/to_python_converter.hpp:34:   instantiated from
`boost::python::to_python_converter<T,
Conversion>::to_python_converter() [with T = agg::matrix<int8u>,
Conversion =
boost::python::objects::class_cref_wrapper<agg::matrix<int8u>,
boost::python::objects::make_instance<agg::matrix<int8u>,
boost::python::objects::value_holder<agg::matrix<int8u> > > >]'
boost_1_31_0/boost/python/class.hpp:105:   instantiated from `void
boost::python::detail::register_class_to_python(boost::mpl::bool_<true>,
SelectHolder, T*) [with T = agg::matrix<int8u>, SelectHolder =
boost::python::objects::select_holder<agg::matrix<int8u>,
boost::python::detail::not_specified>]'
boost_1_31_0/boost/python/class.hpp:631:   instantiated from `void
boost::python::class_<T, X1, X2, X3>::register_() const [with T =
agg::matrix<int8u>, X1 = boost::python::detail::not_specified, X2 =
boost::python::detail::not_specified, X3 =
boost::python::detail::not_specified]'
boost_1_31_0/boost/python/class.hpp:660:   instantiated from
`boost::python::class_<T, X1, X2, X3>::class_(const char*,
boost::python::no_init_t) [with T = agg::matrix<int8u>, X1 =
boost::python::detail::not_specified, X2 =
boost::python::detail::not_specified, X3 =
boost::python::detail::not_specified]'
bpl_src/rendering_buffer.cpp:11:   instantiated from here
agg2/include/agg_matrix.h:124: error: `agg::matrix<T>::matrix(const 
   agg::matrix<T>&) [with T = int8u]' is private
boost_1_31_0/boost/python/object/value_holder.hpp:117: error: within this 
   context






More information about the Cplusplus-sig mailing list