|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-08-19 10:57:59
Christopher Kohlhoff <chris_at_[hidden]> writes:
>> From: Christopher Kohlhoff <chris_at_[hidden]>
>> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk