I would like to iterate over std :: map using BOOST_FOREACH and edit the values. I canβt figure it out.
typedef std::pair<int, int> IdSizePair_t; std::map<int,int> mmap; mmap[1] = 1; mmap[2] = 2; mmap[3] = 3; BOOST_FOREACH( IdSizePair_t i, mmap ) i.second++;
Of course, this does not change anything, because I do not repeat the links. So I will replace this line instead (as per the example in the Boost docs):
BOOST_FOREACH( IdSizePair_t &i, mmap )
and I get a compiler error:
error C2440: 'initializing' : cannot convert from 'std::pair<_Ty1,_Ty2>' to 'IdSizePair_t &' with [ _Ty1=const int, _Ty2=int ]
Any suggestions?
c ++ boost foreach std maps
kmote Apr 27 '09 at 21:55 2009-04-27 21:55
source share