Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-20 08:26:30


From: "Ed Brey" <edbrey_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
> > In short the goal is a std::vector that doesn't give us any excuses to
use
> > _alloca, realloc, new[], VLAs, or even scoped_array.
>
> Don't forget get_temporary_buffer. ;-)
>
> I can envision a compiler making the allocation of vector just as fast as
other forms of allocation, but what about the initialization semantics? All
elements of a vector need be initialized, whereas those in the other types
of allocations do not. For classes of problems where you need to allocate
first and then fill randomly into the buffer, the initialization cost of a
vector is a significant overhead, and I don't see how you could get rid of
it without changing the interface. (Of course, one could create lazy
constructors and copy constructors for the contained objects, but that would
be more horsing around than using, say, a VLA.)
<

People often cite this as a problem with std::vector and propose (good)
solutions. Since I don't think that this is a problem, I don't want it
"fixed." :-) As long as the vector uses memset() whenever possible, of
course.

--
Peter Dimov
Multi Media Ltd.

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