Re: fortran array and std::vector<T>
sebastian sauer wrote:
[..]
my case: a C++ std::vector<T> that is also accessed by a fortran
subroutine as an array.
my question: how shall i do it? what is morale? what is legal? and
what is practical?
void g()
{
std::vector<Foo> v;
...
f(v.begin(), v.size()); // this is what i cannot do i figure
f(&v[0], v.size()); // this is the yuk-dirty way i came up with
}
please enlighten me what is here the best thing to do?
Out of relatively short ones, you've found probably the best way to
do it. The only comment I have: when I knew Fortran, all variables
were passed to it by the address, except the arrays which were passed
by the address of the first element. Of course, today's Fortran can
be different, and I will take your word that the latter call to 'f'
works. If it does, you're there. If it still doesn't, we cannot
really help since Fortran is beyond the scope of a C++ newsgroup.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask