c++ - What is meant by map/set iterator not decrementable? How to make map.rbegin()->first work? -
i trying last element in map of map_of_bit_to_parent
map<long long, long long> ::reverse_iterator itr_rel = map_of_bit_to_parent.rbegin(); long long total_parent_rels = itr_rel->first;
but assignment caused run time error " map/set iterator not decrementable"
how make such assignments?
always test validity of iterator before accessing data through it.
map<long long, long long> ::reverse_iterator itr_rel = map_of_bit_to_parent.rbegin(); long long total_parent_rels = 0; if ( itr_rel != map_of_bit_to_parent.rend() ) { total_parent_rels = itr_rel->first; }
Comments
Post a Comment