Why does clang suggest me to add additional braces when initializing my 2 dimensional standard array? Which would lead to an error. Or am I just not seeing what he wants me to do?
I know that i can add outer braces that would make it clear that i am intializing the first member of the class, but that does not make the warnings go away. I don't think i can add any other braces though.
Compiled on Godbolt with
clang9.0.0 -O0 -std=c++17 -Wall -Wno-unused-value
#include <array>
int main() {
std::array<std::array<float, 3>, 3> {
1,2,3,
1,2,3,
1,2,3
};
std::array<std::array<float, 3>, 3> {{
1,2,3,
1,2,3,
1,2,3
}};
}
I would be ok if the warning would tell me to do the second variant in my example, but it seems that he wants me to wrap the inner array member, which you can't do.
For some information about aggregate initialization: CppRefference
Two versions to create two equal arrays:
#include <array>
int main() {
std::array<std::array<float, 3>, 3> a {{
{1,2,3},
{1,2,3},
{1,2,3}
}};
std::array<std::array<float, 3>, 3> b = {{
{1,2,3},
{1,2,3},
{1,2,3}
}};
}