Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get non-const iterator

Tags:

c++

c++11

auto

std::map<char,int> dict;
...
auto pmax = dict.begin(); // here i get const iterator

Can I "explicitly indicate" that the value obtained is a non-constant type?

like image 280
ObiSan Avatar asked Oct 22 '22 13:10

ObiSan


1 Answers

If your dict is not const, begin will return a std::map<char,int>::iterator. Now, the key is const, but the value is not.

auto should give you a std::map<char,int>::iterator; do you have evidence to the contrary?

like image 150
Alex Chamberlain Avatar answered Oct 24 '22 11:10

Alex Chamberlain