c++ - boost unordered_map key value of 0 -



c++ - boost unordered_map key value of 0 -

i using boost 1.56 , have unordered_map. when insert key value of 0 follows:

boost::unordered_map<int, int> map; for(int i=0; < size; i++) { int value = another_array[j]; map.insert(i, value); }

i crash when accessing map using map.at(0);

i've tested insert works looking @ std::pairiterator, bool>

that insert returns , bool true, indicating inserted creating local global numbering map keys 0:n-1. know n , should able loop on (count == 0:n-1) follows:

for(int j=0; j < count; j++) { if(map.count(j)) printf("value @ index %d %d\n", j, map.at(j)); }

but count of k zero. if don't perform check out of bounds error. how can happening? if switch using 1-n keys there no such problem.

i realise btw in illustration map slight overkill, have reasons.

note can not utilize std::unordered map cross platform , our linux compiler doesn't back upwards it.

before edit: hash<> specialization or equality comparing key_type broken.

you don't show it, kind of invariant-breaking error can explain behaviour describe (in self-contained minimal example), far can tell.

after edit: should create self-contained illustration shows error you, able come improve diagnostics

c++ boost unordered-map

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -