float f[i[1]];
what was the author (Bruce Eckel) trying to say (page 338 Vol 1 second
Edition, Thinking in c++) by giving const array example in this case?
-Krishna.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
According to C++, an array size must be a "integral constant
expression" which has a particular meaning defined by the standard
(5.19). Many of things you might think of as integral constant
expression are (e.g. const int x = 3;). Accessing an element from an
array does not qualify (even though it is an array of const ints).
It seems to me like the compiler should be able to determine the value
at compile time and thus use it as an array size. I am not sure of
the reasoning of excluding it from things allowed as integral constant
expressions.
Another related concept is variable length arrays. This is a feature
of C99 that many C++ compilers support. With this feature, the size
of the array needn't be a constant expression, and the code you
suggested would work.
Absolutely. Only a compile-time array, like boost::mpl::vector_c, can
let you do that, but yeah it's not the same kind of container anymore.