With C ++ 11, you can initialize an instance of an object using {x, y, z} . For instance:
struct P2d { double x, y; }; void foo(P2d p); void bar() { foo({10, 20});
Using it for arrays is fine, and this is also normal for simple cases. In more complex cases, this simply increases confusion, because you only see the values, but you don’t know why these values are used.
This is similar to using an API like
createWindow(0, 0, true, NULL, NULL, 1, NULL, false);
What are these values for?
Just don't overdo the new braces initialization ... there are times when it's fantastic:
// C++03 std::vector<int> list_of_values() { std::vector<int> result; result.push_back(1); result.push_back(2); result.push_back(3); return result; } // C++11 std::vector<int> list_of_values() { return {1, 2, 3}; }
but there are cases in which it is just getting worse:
{Rect(2, 3), Rect(4, 5)}
actually more readable than
{{2, 3}, {4, 5}}
(remember that ease when reading code is much more important than simplicity when writing code ... most lines of code are written once and read many times)