1

How can I make the following code working? I get error 'no match for operator[]`. This is a situation in my application, appearantly there are ways to workaround but I would like to know if this is at all supported.

#include <unordered_map>
#include <utility>

std::pair<int, int> mypair(int a, int b)
{
    return std::pair<int, int>(a, b);
}

int main()
{
    std::unordered_map<std::pair<int, int>, int> mymap;
    mymap[mypair(2, 3)] = 5;
    return 0;
}
StoryTeller - Unslander Monica
  • 165,132
  • 21
  • 377
  • 458
username_4567
  • 4,737
  • 12
  • 56
  • 92
  • Unrelated to your problem, but why make your own `mypair` function instead of using the standard [`std::make_pair`](https://en.cppreference.com/w/cpp/utility/pair/make_pair)? – Some programmer dude Apr 10 '19 at 05:53

0 Answers0