dictionary - map.end() error "iterator not dereferenceable" c++ -




this question has answer here:

//works     cout << "map[0] value " << doublestatsmap.begin()->first<< endl; //gives error cout << "map[last value " << doublestatsmap.end()->first << endl; 

im trying value of last element of map. works correctly "map.begin->first" giving "map/set iterator not dereferencable" "map.end()->first". cant empty map has beginning has end. i've read says should work. suggestions appreciated!

trying end iterator causes undefined behavior.

to last item, can use std::map::rbegin().

// cout << "map[last value " << doublestatsmap.end()->first << endl; cout << "map[last value " << doublestatsmap.rbegin()->first << endl; 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -