[英]Struggling to setup VSCode to compile c++17 or higher on macOS?
我正在学习 C++ 的新功能,在 C++ 17 及更高版本中更新。 我已经将我的 VSCode 设置为使用 Microsoft 的 C/C++ 编译器扩展进行 C++ 编程,并为我的 clang 更新更新了 Xcode。 源代码:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector <int> myints = {1, 2, 3, 4, 5, 6, 7, 8, 9};
for(int i : myints){
cout << i << " ";
}
cout << "\n";
// partition method from STL :
partition(myints.begin(), myints.end(), [](auto x){return xx%2 ==0;});
for(int i : myints){
cout << i << " ";
}
cout << "\n";
return 0;
}
有没有人对如何为 C++ 17 或更高版本更新 clang 有任何建议。 或其他解决我问题的扩展。 先感谢您。
首先,请附上您的主要 src 代码。
其次,您不能在数据字段中初始化向量。 您需要使用成员初始化器列表在构造函数中执行此操作:
MyClass(): myints{1,2,3,4,5,6,7,8,9}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.