小编oto*_*nvm的帖子

没有用于使用clang ++ 3.2初始化'vector <string>'的匹配构造函数

我正在学习c ++与C++ Primer,第5版.

我正在尝试使用clang ++编译一个带有C++ 11特性的简单c ++程序,但是我得到了应该是有效代码的编译错误.

这是一个例子:

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int n = 0;
  auto *p = &n; //<-- this compiles  

  cout << *p << endl;

  vector<string> articles = {"a", "an", "the"}; //<-- this fails; copied from the book

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是完整的错误:

$ clang++ -std=c++11 -v test.cpp -o test
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
 "/usr/local/Cellar/llvm/3.2/bin/clang" -cc1 -triple x86_64-apple-macosx10.6.0 -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model pic -pic-level …
Run Code Online (Sandbox Code Playgroud)

c++ clang c++11

3
推荐指数
2
解决办法
9908
查看次数

标签 统计

c++ ×1

c++11 ×1

clang ×1