Tim Blechmann | 9 Feb 01:09
Favicon

[rfc] sized_array

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
ba.assign(pi);
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

[1]
http://tim.klingt.org/git?p=nova-server.git;a=blob;f=source/utilities/sized_array.hpp;hb=HEAD

--

-- 
tim <at> klingt.org
http://tim.klingt.org

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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Gmane