0

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
theebugger
  • 77
  • 9
  • 2
    Does this answer your question? [Why should I not #include ?](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) – Scheff's Cat May 07 '21 at 05:25
  • It supports the idea. As there is no hint that suggests that the problem is due to that specific line. cmd just goes wild with errors instead of suggesting that it has problems with including bits/stdc++.h. – theebugger May 07 '21 at 05:58

1 Answers1

1

OK, so I figured this out and this came out to be the very first line

#include <bits/stdc++.h>

Including iostream and map instead of the above line results in a clean compilation.

#include<iostream>
#include<map>

Now I have one more reason as to Why should I not #include <bits/stdc++.h>?

theebugger
  • 77
  • 9