Possible Duplicate:
When can outer braces be omitted in an initializer list?
I'm using std::array
in Visual Studio 2010, which is actually std::tr1::array
and I'm running into an annoying issue. I have a function which takes an array
as an argument, for instance.
void do_something(std::tr1::array<int, 5> data)
Calling the function like do_something({1,2,3});
doesn't work and results in a compiler error, however
std::tr1::array<int, 5> data = {1,2,3};
do_something(data);
does. I don't really see why the former wouldn't work. The errors I get tell me I'm missing a )
before the {
. This leads me to believe it's not expecting an initialization list, but I don't see why not. Am I misusing initialization lists?
edit: std::tr1::array
isn't necessary, std::array
works fine..