vendredi 11 juin 2021

how to return a dictionary from a function in cpp

I have this code

#include <map>
#include <tuple>

int test(int x, int y){
   std::map<std::tuple<int, int>, std::string> test_1;
   std::tuple<int, int> test2;
   test2 = make_tuple(x,y);
   test_1.insert<std::pair<std::tuple<int, int>, std::string>(test2, "string");
   return test_1;
}

Error:

'return': cannot convert from 'std::mapstd::tuple<int,int,std::string,std::lessstd::tuple<int,int>,std::allocator<std::pair<const std::tuple<int,int>,std::string>>>' to 'int'

Aucun commentaire:

Enregistrer un commentaire