
2 Sep
2007
2 Sep
'07
8:40 p.m.
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