Skip to content

for each support ? #7425

Answered by Colengms
Another7 asked this question in Q&A
Apr 26, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @Another7 . I do not get errors with the following code:

#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    map<string, int> mymap;
    mymap["surrender"] = 1;
    for (auto [key, value] : mymap)
    {
        cout << key << "---" << value << endl;
    }
    return 0;
}

I suspect you will need to provide a cppStandard setting of c++17 or c++20, for this code to be considered valid. If you have not set cppStandard, it would be the default used by the specified or detected compiler, which likely is not c++17 or c++20.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Another7
Comment options

Answer selected by Another7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants