struct E_Point {
double x, y;
E_Point(): x(0), y(0) {}
E_Point(double x, double y) : x(x), y(y) {}
};
E_Point problem[] = {
{0.3871953044519425, -0.91857980824611341}, // Error: initialization of non-aggregate type 'E_Point' with an initializer list
{0.36139704793723609, 0.91605957361605106},
{-0.8208980020500205, 0.52853407296583088},
{0.36178501611208552, 0.88880385168617226},
{-0.43211245441046209, 0.6803420222771047}
};
Compiling with clang
3.1.
I should point out that this compiles on GCC 4.6.1.
My current understanding is that problem
is a non-aggregate type because it is an array of structs, making it compound and not just simply either a struct or array.
But sending the -std=c++11
flag to clang
does not alleviate the problem.
Update: Okay. Looks like my version of clang
is somehow flawed and can't handle this for whatever reason.
What's a more traditional way to init? Do I do it this way? This compiles, but does it produce the same code? Will it call the ctor while the original doesn't?
E_Point problem[] = {
E_Point(0.3871953044519425, -0.91857980824611341), // 1559
E_Point(0.36139704793723609, 0.91605957361605106), // 1560
E_Point(-0.8208980020500205, 0.52853407296583088), // 1798
E_Point(0.36178501611208552, 0.88880385168617226), // 1799
E_Point(-0.43211245441046209, 0.6803420222771047) // 1800
};