[LC++]STL Iterators and integers

Chris Vine chris at cvine.freeserve.co.uk
Fri Aug 10 10:05:07 UTC 2001


On Thursday 09 August 2001 17:09, Jack Lloyd wrote:

[snip]

> Yeah, I've seen people use v.begin() or &v[0] in an attempt to get an array
> out of it. The begin() option works on Visual C++ (at least I presume it
> does because the code I was looking came from that kind of place) and gcc
> 2.95.x, but not gcc 3.0.

v.begin() is not portable and not at all advisable, as it is not guaranteed 
that a vector interator is a C pointer.  &v[0] is the only safe way of doing 
it, and is (or rather, will be) Std C++ compliant once the contiguity 
guarantee is formally added.

Chris.



More information about the tuxCPProgramming mailing list