If I have a vector of doubles PMF I can divide all elements of the vector by a double count by using the transform command as follows:
transform(PMF.begin(),PMF.end(),PMF.begin(),bind2nd(divides<double>(),count));
Now however, I have a vector of unsigned char/double pairs:
vector<pair<unsigned char, double>> PMF
I wish to replace the double values by their values divided by count. I haven't been able to find a way to do this using the transform command or any other C++11 functionality. Does anyone have an idea as to how to do this?
You can use a lambda function as same as this:
or
or