[C++-sig] Wrapping boost::multi_array
Thomas Kolb
chilavert123 at gmx.net
Wed Jun 15 12:32:23 CEST 2005
Hi all,
I have lots of classes in my library that deal heavily with
boost::multi_array, so I'm trying to wrap this class for some special
dimensions and data types.
My source code is:
namespace {
typedef boost::multi_array<double, 1> DoubleVector;
DoubleVector* cTorWrapper(unsigned int size)
{
return new DoubleVector(boost::extents[size]);
}
double& operatorWrapper(DoubleVector& vec, DoubleVector::size_type id)
{
return vec[0];
}
}// namespace
// Module
======================================================================
void Export_Multi_Array()
{
class_< DoubleVector, std::auto_ptr<DoubleVector> >("DoubleVector")
.def("__init__", make_constructor(cTorWrapper))
.def("get",&operatorWrapper, return_internal_reference< 1 >())
;
}
this leads to the following compiler error:
/usr/local/include/boost-1_31/boost/python/object/make_instance.hpp:
In static
member function `static PyObject*
boost::python::objects::make_instance_impl<T, Holder,
Derived>::execute(Arg&) [with Arg = double*, T = double, Holder =
boost::python::objects::pointer_holder<double*, double>, Derived =
boost::python::objects::make_ptr_instance<double,
boost::python::objects::pointer_holder<double*, double> >]':
/usr/local/include/boost-1_31/boost/python/to_python_indirect.hpp:64:
instantiated from `static PyObject*
boost::python::detail::make_reference_holder::execute(T*) [with T =
double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:19:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_type_cv(U*,
boost::python::detail::cv_tag<false, false>, Generator*) [with
Generator = boost::python::detail::make_reference_holder, U = double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:48:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_ptr_type(U*, Generator*) [with Generator
= boost::python::detail::make_reference_holder, U = double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:58:
instantiated from `static typename Generator::result_type
boost::python::detail::unwind_helper<is_ptr>::execute(U, Generator*)
[with Generator = boost::python::detail::make_reference_holder, U =
double*, bool is_ptr = true]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:77:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_type(const U&, Generator*) [with
Generator = boost::python::detail::make_reference_holder, U = double*]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:26:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_type_cv(const U*,
boost::python::detail::cv_tag<true, false>, Generator*) [with
Generator = boost::python::detail::make_reference_holder, U = double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:48:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_ptr_type(U*, Generator*) [with Generator
= boost::python::detail::make_reference_holder, U = const double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:69:
instantiated from `static typename Generator::result_type
boost::python::detail::unwind_helper<false>::execute(U&, Generator*)
[with Generator = boost::python::detail::make_reference_holder, U =
const double]'
/usr/local/include/boost-1_31/boost/python/detail/unwind_type.hpp:77:
instantiated from `typename Generator::result_type
boost::python::detail::unwind_type(const U&, Generator*) [with
Generator = boost::python::detail::make_reference_holder, U = double]'
/usr/local/include/boost-1_31/boost/python/to_python_indirect.hpp:105:
instantiated from `PyObject* boost::python::to_python_indirect<T,
MakeHolder>::operator()(T) const [with T = double&, MakeHolder =
boost::python::detail::make_reference_holder]'
/usr/local/include/boost-1_31/boost/python/detail/invoke.hpp:76:
instantiated from `PyObject*
boost::python::detail::invoke(boost::python::detail::invoke_tag_<false,
false>, const RC&, F&, AC0&, AC1&) [with RC =
boost::python::to_python_indirect<double&,
boost::python::detail::make_reference_holder>, F =
double&(*)(<unnamed>::DoubleVector*, long unsigned int), AC0 =
boost::python::arg_from_python<<unnamed>::DoubleVector*>, AC1 =
boost::python::arg_from_python<long unsigned int>]'
/usr/local/include/boost-1_31/boost/python/detail/caller.hpp:199:
instantiated from `PyObject*
boost::python::detail::caller_arity<2>::impl<F, Policies,
Sig>::operator()(PyObject*, PyObject*) [with F =
double&(*)(<unnamed>::DoubleVector*, long unsigned int), Policies =
boost::python::return_internal_reference<1,
boost::python::default_call_policies>, Sig =
boost::mpl::vector3<double&, <unnamed>::DoubleVector*, long unsigned
int>]'
/usr/local/include/boost-1_31/boost/python/object/py_function.hpp:39:
instantiated from `PyObject*
boost::python::objects::caller_py_function_impl<Caller>::operator()(PyObject*,
PyObject*) [with Caller =
boost::python::detail::caller<double&(*)(<unnamed>::DoubleVector*,
long unsigned int), boost::python::return_internal_reference<1,
boost::python::default_call_policies>, boost::mpl::vector3<double&,
<unnamed>::DoubleVector*, long unsigned int> >]'
/usr/local/include/boost-1_31/boost/python/make_constructor.hpp:40:
instantiated from here
/usr/local/include/boost-1_31/boost/python/object/make_instance.hpp:25:
error: invalid
application of `sizeof' to an incomplete type
returning the result of operator[] by values compiles great, but
that's not what I want.
Anybody has an idea what's wrong?
Best Regards
More information about the Cplusplus-sig
mailing list