Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by vmp for Unknown type name error when inserting into unordered_map

I don't know why it is not working, but you don't need to call make_pair...Changing the insertion line to:

firstSets.insert({decl, declFirstSet});

Should solve your problem.

Here would be a full code example:

#include <set>#include<string>#include <unordered_map>using namespace std;int main(){    std::unordered_map<std::string, std::set<int>> firstSets;    set<int> s = { 1, 2, 3 };    firstSets.insert({ "key", s });   }

But seems like you want them declared in global scope, so you would initialize like the following code:

#include <set>#include<string>#include <unordered_map>using namespace std;set<int> s1 = { 1, 2, 3 }, s2 = { 4, 5, 6 };std::unordered_map<std::string, std::set<int>> firstSets{ {"key1", s1}, {"key2", s2}};int main(){}

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>