0
votes

My question is an extension of the following question: Searching and Inserting in a map with 3 elements in C++

In addition to the above-mentioned case, I would like to have an extra pair in map as given below definition.

std::unordered_multimap<unsigned int, 
      std::pair< std::pair<unsigned int, unsigned int>, float>> wedgeAlphaMap;

This does not work well. All the time when I emplace values for the second variable in the pair(i.e. vi2), I am getting a garbage value. (code shown below)

wedgeAlphaMap.emplace(vi0, std::make_pair(std::make_pair(vi1,vi2), alpha) );

This is how I am getting(note: the vi2 for all)

vi0: 2762     vi1:2758       vi2:0     Alpha:90.0000 
vi0: 2762     vi1:2761       vi2:-1610612736     Alpha:11.2407 
vi0: 2762     vi1:2763       vi2:-536870912     Alpha:78.7593 
vi0: 2762     vi1:2767       vi2:1073741824     Alpha:50.4362 
vi0: 2762     vi1:2759       vi2:-1073741824     Alpha:39.5638 
vi0: 2762     vi1:2769       vi2:0     Alpha:90.0000 
vi0: 40     vi1:1       vi2:-1610612736     Alpha:67.5731 
vi0: 40     vi1:41       vi2:-2147483648     Alpha:67.5728 
vi0: 40     vi1:35       vi2:0     Alpha:90.0000 
vi0: 40     vi1:375       vi2:1073741824     Alpha:48.3076 
vi0: 40     vi1:376       vi2:-1073741824     Alpha:41.6924
and so on...................................

Printing before emplacing them to the map:

The vi0: 40 , vi1: 1 , vi2: 376
The vi0: 1 , vi1: 376 , vi2: 40
The vi0: 376 , vi1: 40 , vi2: 1
The vi0: 376 , vi1: 1 , vi2: 377
The vi0: 1 , vi1: 377 , vi2: 376
The vi0: 377 , vi1: 376 , vi2: 1
The vi0: 3 , vi1: 195 , vi2: 193
The vi0: 195 , vi1: 193 , vi2: 3
The vi0: 193 , vi1: 3 , vi2: 195
The vi0: 193 , vi1: 195 , vi2: 194
The vi0: 195 , vi1: 194 , vi2: 193
The vi0: 194 , vi1: 193 , vi2: 195
The vi0: 97 , vi1: 5 , vi2: 98
The vi0: 5 , vi1: 98 , vi2: 97
The vi0: 98 , vi1: 97 , vi2: 5
The vi0: 98 , vi1: 5 , vi2: 99
The vi0: 5 , vi1: 99 , vi2: 98
The vi0: 99 , vi1: 98 , vi2: 5
and so on...................................

How I can properly make use of it/ or do I have missed something?

Try to print out values you are emplacing (vi2) to see if they have garbage values there. BTW, why don't you use std::tuple instead of pair of pair? - Daniel Langr
Here is a handy chart of bugs that can appear in stackoverflow questions. Handmade by yours truly, enjoy. - n. 1.8e9-where's-my-share m.
@DanielLangr : Yes I have printed the values before emplacing. That was correct. But while emplacing, that's not getting correctly emplacing. - user9267359
@n.m. why do you think, its handmaid? I really did not get your point?. - user9267359
@Jackyone Can you provide a minimal working example? - Daniel Langr