c++11 Uniform initialization does not work with clang++
c++, c++11, clang
Solution
The hint is actually here:
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
^~~~~~
This means that it is not the 3.1 version proper, but somewhere between 3.0 and 3.1.
The support for uniform initialization was implemented somewhere between those two versions so the version that Apple has probably has either absolutely no support or just partial support.
Problem
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; } ``` I then 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 clang version `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 ``` Shouldn't this example work? Maybe clang just isn't fully c++11 compatible yet? What's going on?