c++ - using BOOST_FOREACH with std::map -


I want to redo a std :: map using the BOOST_FOREACH and edit the values. I can not take it a lot

  typedef std :: pair and lt; Int, int & gt; IdSizePair_t; Std :: map & lt; Integer, integer & gt; Mmap; Mm [1] = 1; Mm [2] = 2; Mm [3] = 3; BOOST_FOREACH (IdSizePair_t i, mmap) i.second ++; // mmap should be {2,3,4} here  

Of course this is not changing anything because I am not running again from context. Therefore, instead of this line option (as in the Boost Doc example):

  BOOST_FOREACH (IDSIPPAR_IT and M, MMAP)  

and I found Compiler Error:

  Error C2440: 'Start': 'std :: pair & lt; _Ty1, _Ty2 & gt; Can not be changed from IDSIPPAR_AT & amp; Any suggestions?   

> < P> Problem is with the first member of the pair, which should be const Try it:

  typedef std :: map & lt; Int, int & gt; Map_t; Map_t mmap; BOOST_FOREACH (map_t :: value_type & amp; i, mmap) i.second ++;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -