stl map access problem..

hey guys, i think i need your help.
So, i have a map with the following form :
map<string,list<pair<int,int>>>.
I try to access the list via the string name :

1
2
3
4
5
6
7
8
9
map<string,list<pair<int,int>>> basic;

/*i insert elements at the structure........*/

/*now i have to pass the lists as arguments in a function with prototype
  void foo(list<pair<int,int>> arg0, list<pair<int,int>> arg1);
*/

foo(basic["list1"] , basic["list2"];




but it doesn't work.. I have not compile errors or warnings but the function
does not see the arguments..
Any idea?? Thanks!

but it doesn't work..

What's the symptoms? Tell in more detail, please.
the symptom is the following :
when i make the lists "by hand"
for example :
1
2
3
4
5
6
7
8
9
10
11
12
13
list<pair<int,int>> list1;
list<pair<int,int>> list2;

list1.push_back(make_pair(1,1));
list1.push_back(make_pair(1,2));

list2.push_back(make_pair(2,2));
list2.push_back(make_pair(1,3));

//and call the function foo
foo(list1 , list2);

// 

the function foo works normaly,, in foo i iterate the lists normaly.

But when i m trying to get the lists from a map (the insertions in the map lists are tested from another main and they are working normaly) my program doesn't work. The program uses the allegro library and that makes difficult to debug from the program (e.g using a cout).
So, when i say "it doesn't work" means that i don't have compile errors or warnings but the function does nothing. You can say that the function foo "see" the lists empty but they are not....
Last edited on
More info! The case is interesting but all telepathists are taking their vacation.

Or give the foo, we'll try to debug.
i can't give more info mate because i have to find the solution alone ;)
If u have any idea how to "take" the lists from the map with their names i would be thankful.
The only think that is very sure is that the foo is working normally when i pass simple lists as "by hand".
Do u have any idea how to take the lists from the map??

is this the right way??
1
2
3
4
5
6
7
8
9
map<string,list<pair<int,int>>> basic;

/*i insert elements at the structure........*/

/*now i have to pass the lists as arguments in a function with prototype
  void foo(list<pair<int,int>> arg0, list<pair<int,int>> arg1);
*/

foo(basic["list1"] , basic["list2"];
Only problem I see here is that you're adding items to your lists in your "by hand" example, but aren't adding any items to your lists in your other example.

Could it be that you just aren't adding items to these lists? Are you sure you're using the right key? etc etc
Could it be that you just aren't adding items to these lists? Are you sure you're using the right key? etc etc


Playing telepathist? ;)

karvoyno, can you show how you insert lists into the map? When do you fill them - before the insertion or when they are already in the map? How?
Last edited on
I insert the elements in the map - lists with another function which reads a file and takes the elements.. I tested that function in another no-allegro program and it was ok..
Do i need any iterator to take the elements from the map? Any idea?

Last edited on
i think i found the solution.. Thanx everyone that helped guys..
The problem was that the lists was empty.. and i have to fix this now :(
good night!
Topic archived. No new replies allowed.