Boost logo

Boost :

Subject: [boost] [rfc] sized_array
From: Tim Blechmann (tim_at_[hidden])
Date: 2010-02-08 19:09:36

hi all,

i have a small class, something between std::vector and boost::array. if
others find it useful, i could submit it as an extension to the
boost.array libray.

it basically implements a dynamically sized array, similar to
boost::array, but its size can be defined at run-time, rather than
compile-time. in contrary to std::vector, which is only required to
support random-access iterators (which are implementation-defined), my
class guaranties to allocate the data in one consecutive memory area. it
can basically be used like boost::array, the only difference is its
constructor, which takes either an integer size or a container.

boost::array<float, 5> ba;
sized_array<float> sa(5); // initialize to size 5
assert(sa.size() == ba.size()); // container size
sa.assign(pi); // assignment
sized_array<float> sa2(ba); // construct from container

the code is available at [1], would be interested to hear, if other
people find it useful ..

thanks, tim


Art is either a complaint or do something else
  John Cage quoting Jasper Johns

Boost list run by bdawes at, gregod at, cpdaniel at, john at