I believe std::for_each looking for a function with a return type of void. You pass a function with a double return type. Jpalecek's answer is correct, but +1 to him. However, you still have a semantic problem that doing for_each with the log makes no sense:
If you want all the members of the vector to be a journal of the previous members, that is:
//pseudocode foreach( var x in myvector ) x = log(x);
Then you do not want for_each , you want transform .
std::transform(vec.begin(), vec.end(), vec.begin(), log);
source share