Re: [Boost-users] question: boost::array does not have compile time checked access
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. Even if you can attach a specific meaning for individual elements, most of the processing is still done either by iterating over the array or by accessing an element based on an index number extracted from incoming data. In general rogramming the occassions where you would be accessing the array by a constant index is still very rare compared to accessing the elements by a variable index. Even if you did have an application where almost all of the array accesses were with constant indexes, then you would also certainly create a set of constants so that you would, say, extract the state name from an array of address strings by saying [WYOMING] rather than [49]. You set the constants up once and you're done. No more array bounds access errors. Even if the initial set of constant definitions had an error, once fixed, it's fixed forever. Again, the number of places where checking array bounds on fixed length arrays is too small to justify work involved. Merrill
Merrill Cornish
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
participants (2)
-
gast128
-
Merrill Cornish