Re: tr1::array initializater syntax
On 2008-02-14 16:00:20 -0500, Jeff Schwab <jeff@schwabcenter.com> said:
The latest GCC (4.2.3) gives a warning if a tr1::array is initialized
with the traditional syntax:
#include <iostream>
#include <tr1/array>
int main() {
std::tr1::array<int, 35> a = { 0 };
std::cout << a[4] << '\n';
}
g++ -ansi -pedantic -Wall main.cc -o main
main.cc: In function 'int main()':
main.cc:5: warning: missing braces around initializer for 'int [35]'
Is this the expected behavior? What's the short, static way to
initialize a tr1::array of arbitrary size?
The compiler is telling you that you might not know what you're doing,
despite the fact that this initialization is legal and its meaning is
well defined. If you agree with the compiler writer's stylistic
judgment, change the code. Personally, I don't think any compiler
writer knows enough about the code that I'm writing to tell me how I
should write it. Turn off the warning.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)