$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: gast128 (gast128_at_[hidden])
Date: 2005-08-07 16:46:52
Merrill Cornish <merrill.cornish <at> earthlink.net> writes:
> 
> >>> the places where you would use fixed arrays, 
> >>> you probably also know at what indexes certain data resides.
> 
> If you use fixed arrays in that way, then you are using them much like 
structs where, say, [0] mean THIS and [1]
> means THAT and [2] means something else etc.  If that were the case, then 
individually named variables
> would likely work better.
> 
> The more common reason for fixed arrays is that the array is matching 
something in the real world:  I'm doing a
> 256 element Fast Forier Transform, I'm processing census data for 50 US 
states, I'm tallying sales for the
> 12 months.
Your own argument exactly describes my case: you have a fixed array for the 
months, so you know in which position the month november is. With enumerates 
this mapping can be done easily.
 
> Again, the number of places where checking array bounds on fixed length 
arrays is too small to justify work involved.
> 
If you don't need it, don't use it. I hardly uses reverse iterators, but that 
doesn't mean that they are useless, or don't justify their existance. Further 
you use big words for such a small enhancement. A simple implementation would 
be something like:
template <typename T, std::size_t N>
class array
{
  template <unsigned u>
  T& get()
  {
     BOOST_STATIC_ASSERT(u < N); 
     return elems[u];
  }
};
A golden rule is alays to use as much error checking as possible, which is 
compile time error checking.
Wkr,
me