|
Boost Users : |
Subject: Re: [Boost-users] Is it ok to pass &my_boost_array_variable[2] into a C function expecting a Type*
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-11-29 11:41:36
AMDG
On 11/29/2012 01:47 AM, Anton Daneyko wrote:
> Hi,
> I have a two variables:
> boost::array my_boost_array_variable_1<float, 3>;
> boost::array my_boost_array_variable_2<float, 3>;
>
> now I want to call a C function with the following signature:
> int MPI_Allreduce ( void *sendbuf, void *recvbuf, ...);
>
> I want to pass the address of a particular element of my
> my_boost_array_variable_1 and my_boost_array_variable_2 as a first
> and second parameter of MPI_Allreduce:
> MPI_Allreduce(&my_boost_array_variable_1[2],
> &my_boost_array_variable_2[2], ...
>
Yes, this is legal. A pointer is a pointer,
regardless of how you get it and all of the
intermediate expressions are legal too.
> or should I rather do:
> MPI_Allreduce(my_boost_array_variable_1.c_array() + 2,
> my_boost_array_variable_2.c_array() + 2, ...
>
In Christ,
Steven Watanabe
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