Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-09-03 11:52:07


on Sun Sep 02 2007, "David A. Greene" <greened-AT-obbligato.org> wrote:

> Bo Persson wrote:
>> :: &a[0];
>> ::
>> :: The C++ community promotes std::vector as a C array replacement,
>> :: but
>> :: it's really not because it's not legal to do the above operation
>> :: when
>> :: the vector is empty.
>>
>> That's just a misuse of the std::vector. You never, ever get the idea
>> of taking the address of an empty array. Why attempt that on an empty
>> vector??
>>
>
> Dunno what you mean by "get the idea of taking the address," but
> this is a perfectly reasonable thing to do in C.

Writing x[n] is undefined behavior in C++ whenever n >= the length of
the array. Is C different in that regard?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk