Boost logo

Boost :

From: Bo Persson (bop_at_[hidden])
Date: 2007-09-02 16:40:20


David Greene wrote:
:: BTW, the specific issue that keeps coming up involves taking the
:: address
:: of the first element of an empty std::vector:
::
:: &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??

:: I believe this is because the vector
:: interface
:: is characterized in terms of iterators rather than addresses.

Yes, so a.begin() works even for an empty vector. Why is the address
so interesting?

Bo Persson


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