samedi 3 juin 2023

How do i declare an unordered_map of an unordered map and a vector of strings?

I was trying and got to the following code

#include <unordered_map>
#include <vector>
#include <string>
using namespace std;

int main() {
    unordered_map<char, int> myMap;
    vector<string> myVector;
    unordered_map<unordered_map<char, int>, vector<string>> myUnorderedMap;
    myUnorderedMap[myMap] = myVector;
    return 0;
}

I get the following errors:

main.cpp: In function ‘int main()’:
main.cpp:9:61: error: use of deleted function ‘std::unordered_map\<\_Key, \_Tp, \_Hash, \_Pred, \_Alloc\>::unordered_map() \[with \_Key = std::unordered_map; \_Tp = std::vector \>; \_Hash = std::hash \>; \_Pred = std::equal_to \>; \_Alloc = std::allocator, std::vector \> \> \>\]’
9 |     unordered_map\<unordered_map\<char, int\>, vector\<string\>\> myUnorderedMap;
|                                                             ^\~\~\~\~\~\~\~\~\~\~\~\~\~
In file included from /usr/include/c++/11/unordered_map:47,
from main.cpp:1:

I am trying to create an unordered_map of an unordered map and a vector of strings in c++ something like that unordered_map<unordered_map<char, int>, vector<string>> myUnorderedMap;

Aucun commentaire:

Enregistrer un commentaire