jeudi 6 mai 2021

g++ -std=c++17 gives lines and lines of errors

I am trying to compile this code with MinGW g++ (i686-win32-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
   map<int, int> mmap;
    mmap[0]=10;
    mmap[1]=20;
    mmap[2]=30;
    mmap[3]=40;
    mmap[4]=50;
    for(auto [x,y]:mmap){
        cout<<x<<"->"<<y<<endl;
    }
    return 0;
}

Compiling with c++11 flag gives this

E:\Code>g++ temp.cpp -std=c++11
temp.cpp: In function 'int main()':
temp.cpp:89:14: warning: structured bindings only available with -std=c++17 or -std=gnu++17
     for(auto [x,y]:mmap){

and compiling with c++17 flag gives lines and lines of errors.

g++ temp.cpp -std=c++17

Aucun commentaire:

Enregistrer un commentaire