Boost logo

Boost :

From: Michiel Salters (Michiel.Salters_at_[hidden])
Date: 2001-08-21 15:30:48


I.e. what we need is an std::vector<T>::uninitialized_resize(n),
for builtin Ts, which combines the speed of reserve(), and the
guarantee of resize) that the memory can be written to, just not
the guarantee that the memory can be read.

Regards,
Michiel Salters.

> -----Original Message-----
> From: Ed Brey [mailto:edbrey_at_[hidden]]
> Sent: Monday, August 20, 2001 7:00 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Re: Technical session at the October C++ meeting?
>
>
> From: "Vesa Karvonen" <vesa.karvonen_at_[hidden]>
> > From: "Ed Brey" <edbrey_at_[hidden]>
> > [...]
> > > The question is: how should one program algorithms that
> need deferred
> > > initialization of elements? If vector is to be the end
> all and do all
> > > dynamic array type, replacing VLAs et al., it needs to answer this
> > > question.
> > [...]
> >
> > Standard vector does support a form of deferred
> initialization: you are
> > allowed to reserve space for elements that can be
> initialized later by using
> > vector methods such as assign, push_back, etc...
>
> Yes. However, this covers only one special case of the
> general problem. In the general problem, consider that you
> have 10 objects have an inherent order, and you want them
> placed in contiguous space in memory. The order in which you
> obtain the information needed to construct each object is
> unspecified, so you may first construct v[8], then v[1], and
> so on. The combination of reserve() and push_back() is
> helpful only when the order is v[0], v[1], etc. Assign() is
> useful only when all the data for the vector is available at once.


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