Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-02-04 12:03:43

--- At Mon, 4 Feb 2002 00:28:32 -0800, Darin Adler wrote:

>On 2/3/02 11:54 PM, "Jon Wang" <webmaster_at_[hidden]> wrote:
>> 1. Mr Stroustrup said that there wasn't a need for auto_array, for "a
>> solution is to use a vector". So, should we use vector or
>> scoped_array/shared_array?
>You should normally use std::vector unless you have some special reason to
>use boost:: scoped_array and boost::shared_array. Those classes are provided
>both for completeness, and because occasionally there are such special
>reasons. But not often.

I consider user vector<> often. However there is a cost. For a fixed size
allocation of a buffer there is only the data allocated. If you use a
vector<> the vector also includes (for most implementations) the current
capacity, the current size, and the allocator.

I would be interested in finding a class that is somewhere between
allocating my own buffers and vector<>. Low overhead for simple
allocations; no resizing or growing. Even in this case, in order to
support iterator semantics the size is going to be needed.


I suppose a case like this might be when scoped_array would be used?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at