Boost logo

Boost Users :

From: Bo Peng (bpeng_at_[hidden])
Date: 2004-06-14 11:03:52


Dear list,

I frequently need to use arrays with undetermined (at compile time) but
constant (user specify size) size. I.e., I need something like

  boost::array<int> arr(5);

without arr.insert etc, rather than

  boost::array<int,5> arr;

which only accept constant array length.

Of course I can use 'vector<int> arr(5)' in this case but I am worry
about the performance and size overhead, specifically:

1. How is size() implemented in vector<>? I am concerned with this
function since icc (intel c++ compiler) can not vectorize
'for(i=0;i<arr.size();i++)' unless arr.size() is an inlined reference to
a variable.

2.Since I will have a lot of such arrays, I would also like to know how
many additional variables vector<int> keeps. I.e. exactly how big is
vector<int> arr(5)?

It might be trivial to copy boost::array and add constructor/destructor
but I do not want to re-invent the wheel.

Thanks.
Bo


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