I copied the following example from this wikipedia page :
struct BasicStruct { int x; double y; }; struct AltStruct { AltStruct(int x, double y) : x_{x}, y_{y} {} private: int x_; double y_; }; BasicStruct var1{5, 3.2}; AltStruct var2{2, 4.3}; int main (int argc, char const *argv[]) { return 0; }
Then I tried to compile it with
clang++ -Wall -std=c++11 test.cpp
but I get this error:
test.cpp:17:11: error: non-aggregate type 'AltStruct' cannot be initialized with an initializer list AltStruct var2{2, 4.3}; ^ ~~~~~~~~ 1 error generated.
My version of clang clang++ --version is
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn) Target: x86_64-apple-darwin11.4.0 Thread model: posix
Should this example not work? Maybe clang is just not fully compatible with C ++ 11?
What's happening?
source share