#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector<int> v = {1,2,3,4};
for (int x : v)
{
cout << x << ' ';
}
return 0;
}
When I run the above code in vscode I receive the following ERROR:
non-aggregate type 'vector' cannot be initialized with an initializer list gcc [7, 17]
NOTICE - the error includes gcc even though that is not the compiler I am using.
The code compiles fine in the terminal and in Xcode so I know it has something to do with vscode. How do I fix this issue?
NOTE - I am using I C/C++ IntelliSense with the following configurations: Compiler Path (/usr/bin/clang++) IntelliSense mode (macros-clang-arm64) Include path (${workspaceFolder}/**) C standard (c17) C++ standard (C++17).