Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2003-06-10 21:15:19


--- At Tue, 10 Jun 2003 16:19:54 -0400, Daryle Walker wrote:

>On Tuesday, June 10, 2003, at 3:20 PM, Duane Murphy wrote:
>
>[SNIP]
>> [ I expect a correction flood on this one. :-) ]
>>
>> In fact, vector<> is guaranteed to be contiguous. It is the only
>> standard container that satisfies this requirement.
>
>I think the contiguous requirement is only given in a correction
>report, not in the standard itself.

That is correct. However, the correction was mostly accademic as it was
understood that no one had actually implemented a vector that wasnt
continguous.

>But my point was that if the OP
>only needed a simple byte bucket, he could just allocate one without
>complicating matters with a full-blown object. It's more efficient
>because the multi-byte processing function only works with simple byte
>buckets.

This used to be my consensus as well. However, after reading Meyer's More
Effective STL as well as several CUJ articles I became convinced that
there was virtually no overhead and lots of convenience to actually using
a vector instead of "raw" storage. The automatic size management coupled
with automatic destruction is a huge win over raw allocated storage
management. In addition, most standard libraries have optimized vectors
for pod's that remove the overhead of constructing and destructing
intrinsic types and pointers.

My conclusion was that vector<> is your friend. :-)

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net