
I have a vector of strings and I have a map that maps one string to another. How can use transform for that? This is how I do it right now: map<string, string> mapping; vector<string> strings; for(vector<string>::iterator s=strings.begin();s!=strings.end();++s) *s=mapping[*s]; I would like something like: transform(strings.begin(),strings.end(),strings.begin(),_1=mapping[_1]); Or maybe there is a predicate that already does it? I can write my own: template<T> struct mapit: public unary_function<T,T> { map<T,T> mapping; mapit(const map<T,T>& m):mapping(m){} T operator()(const T& s){return mapping[s];} } transform(strings.begin(),strings.end(),strings.begin(),mapit<string>(mapping)); Is it the proper way to do such a transformation? Thanks. -- Regards, Alexander. http://sjcomp.com