Mac上的clang不支持统一初始化吗?
我尝试编译以下代码,但编译器引发错误。
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<int> v = {3, 1, 9, 4};
std::cout << v[1] << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
错误:
vector.cpp:9:22: error: non-aggregate type 'std::vector<int>' cannot be initialized with an initializer list
std::vector<int> v = {3, 1, 9, 4};
^ ~~~~~~~~~~~~
1 error generated.
Run Code Online (Sandbox Code Playgroud)
操作系统:macOS 10.12.4
编译器版本:
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
485 次 |
| 最近记录: |