|
Boost Users : |
From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2006-07-03 16:04:02
Sebastien Fortier wrote:
> Thank you very much Daniel!
>
> I had another question, is it possible to use multi_array and
> const_multi_array_ref together in python.
> What I mean is, if I create a multi_array from python through my c++
> functions and I want to pass this array to another c++ function that
> uses a const_multi_array_ref how do I manage this in the interface file?
> is this possible?
>
> I added class_<const_multi_array_ref<double, 2>
> >("const_multi_array_2d_ref"); to my interface file but the types seem
> to be incompatible.
You need to let Boost.Python know that the types are convertible:
implicitly_convertible<
multi_array<double, 2>
, multi_array_ref<double, 2>
>();
implicitly_convertible<
multi_array<double, 2>
, const_multi_array_ref<double, 2>
>();
Should do it. See http://www.boost.org/libs/python/doc/v2/implicit.html.
> I would prefer to use the const_multi_array_ref with the multi_arrays to
> avoid copies...
If you already have multi_array's, why don't you just pass them by
reference?
-- Daniel Wallin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net