* Jim Langston:
Daniel Kraft said:
Anyway, to get at the internal array in a vector v, e.g. for the purposes
of passing to some C function, simply do &v[0].
This works of course for the usual concept of a vector -- but is this
guaranteed to work? To me it seems like maybe safe but still dirty
hack...
As V says, it is required to work, and is the way it's normally done. I
just wish that std::string had this same requirement, would make things a
lot easier.
It has, in two senses. (1) The in-practice, no current standard library
implementation is known to not support that. (2) The in-future, the
library working group adopted contiguous storage for strings about a
year (or is it now two years?) ago, Lillehammer meeting, same as for
vector, and that will be in C++0x.
So, things /are/ actually a lot easier. ;-)
However, the lack of a standard read-only string carrier class (with
specificiable destruction function) means that less than half of the
solution is in place in C++. That's not very sensible. If I weren't so
darned sure that nothing would eventually come of it, or that if
something came of it I'd not have the means to follow it through, I'd
make a proposal -- but hey, the world is full of people, a great
number of them are C++ programmers, some of those are even competent,
and there just must be at least one of the competent who can do this?