
19 Aug
2005
19 Aug
'05
3:57 p.m.
Christopher Kohlhoff <chris@kohlhoff.com> writes:
From: Christopher Kohlhoff <chris@kohlhoff.com> Don't construct a vector of a given size or use resize(), then. Rely on reserve() instead.
It's my understanding that you cannot access the address &vec[N] (or &vec[0] + N) unless 0 <= N < size(), and reserve() doesn't change the size of the vector.
That's correct. There's been some discussion of providing a vector ctor (and assign member) that takes a number of elements and function object that can be used to construct the elements into its raw memory. Until we have that, std::vector is probably the wrong tool for this job. -- Dave Abrahams Boost Consulting www.boost-consulting.com