-6

I have the following map in C++:

typedef std::pair<int, int> iPair;

std::map< iPair, std::list< iPair > > world;

I want to make insert and update of the map for a pair(u,v) -> push back in list:

 iPair src = make_pair(p1, u1);
 iPair dst = make_pair(p2, u2);
 map[src].push_back(dst);

I get a compiling error when trying to access map[src]:

error: missing template arguments before ‘[’ token

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
georgiana_e
  • 1,809
  • 10
  • 35
  • 54
  • 6
    Not `map[src]`, but `world[src]` - that's the name of your variable, isn't it? – jlahd Aug 19 '17 at 15:20
  • 3
    Chances are you have `using namespace std;` which is causing your use of `map` to be resolved to `std::map` which requires a template parameter like the error says. – Gambit Aug 19 '17 at 15:22

1 Answers1

4

You need world[src] since that is the name of your map variable, that should work.

Cuber
  • 713
  • 4
  • 17