clang支持Mac OS X上的聚合初始化

时间:2013-06-01 22:01:05

标签: macos c++11 clang clang++

我正在尝试在mac上的clang ++上编译C ++ 11 list congregation初始化。

#include <iostream>
#include <list>
#include <string>

using namespace std;
int main(int argc, char *argv[]) {
    list<string> aList = {"abc", "def", "xyz"};
}

这是编译的命令。

clang++-mp-3.1 -std=c++11 iterator.cpp

我没有匹配的构造函数错误。

iterator.cpp:7:23: error: no matching constructor for initialization of
  'std::list<string>'
std::list<string> aList = {"abc", "def", "xyz"};
                  ^       ~~~~~~~~~~~~~~~~~~~~~

我尝试使用XCode

clang -v
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

我也尝试过来自

的clang ++
clang++-mp-3.1 -v
clang version 3.1 (branches/release_31)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

我得到了相同的结果。可能有什么问题?

clang's support of C++ 11 lambda

1 个答案:

答案 0 :(得分:0)

我试过icc,得到了同样的错误。我想问题是模板而不是编译器。 icc使用现有模板/usr/include/c++/4.2.1,并且该实现不完全支持c ++ 11。

我从端口

尝试了gcc 4.8
sudo port install gcc48

工作正常

/opt/local/bin/g++-mp-4.8 -std=c++11 Iterator.cpp 

How to turn on C++0x of Intel C++ Compiler 12.1.2

相关问题