alan
11/24/2008 2:26:00 PM
First off, here's what I want to do: I want to iterate over the key-
value pairs of an std::map, and change only its value.
AFAICT, however, std::map::begin() returns a const_iterator, so I
can't actually change the value using just the iterator. What I
thought I'd do would be, I'd iterate using the iterator, get the key,
then use std::map::operator[] to change its values, like so:
typedef std::map<Generic*, Generic*> trmap;
for(trmap::iterator it = m.begin(); it != m.end(); ++i) {
Generic* K = it->first;
m[K] = transforming_function(m[K]);
}
Would this be valid and standards-compliant?