You're wrong, of course. If you can get a reference, you can
get a pointer.
Of any of the elements. (At least, I think that's what you
mean; "all of the elements" is ambiguous, and can mean two
different things.)
I think that valarray is guaranteed to be continuous. As is
std::vector, and (soon) std::basic_string. That's not true for
other containers, however, and a pointer to a given element is
not generally a random-access iterator into the container.
(Again, I think you know this, and were only refering to
valarray, but it's not clear.)
The most frequent need for a pointer is, of course, interfacing
with legacy code or with C. In which case, the type of the
container is constrained; if the C code expects a pointer to the
first element, you can use vector, I think valarray, and in
practice basic_string, but nothing else.
--
James Kanze (GABI Software) email:
[email protected]
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34