> Hi all,
>
[quoted text clipped - 6 lines]
> contiguous memory, so that I can use vector.begin() as a pointer to the
> memory containing my contiguous array of data?
Yes, you are.
-cd
> Hi all,
<snip>
> My question is, am I guaranteed
> that the vector stores its data in contiguous memory,
Practically speaking yes (although it is not yet in the norm, it will soon
be).
> so that I can
> use vector.begin() as a pointer to the memory containing my
> contiguous array of data?
That, on the other hand, is wrong : there is no guarantee than a vector
iterator can be used as a pointer : You can use &MyVect[0] to get a pointer
to the begnning of the vector buffer.
Arnaud
MVP - VC
Tom Widmer - 23 Mar 2005 11:25 GMT
>>Hi all,
>
[quoted text clipped - 5 lines]
> Practically speaking yes (although it is not yet in the norm, it will soon
> be).
The 2003 standard says it explicitly: "The elements of a vector are
stored contiguously, meaning that if v is a vector<T, Allocator> where T
is some type other than bool, then it obeys the identity &v[n] == &v[0]
+ n for all 0 <= n < v.size()."
Tom