You guys were right, I forgot that it was debug release
when run in release mode, I get:
Time: BOOST_FOREACH(Fred& fred, vec) { fred.inc(); } 0.28
Time: std::for_each(vec.begin(),vec.end(),boost::bind(&Fred::inc,_1) ); 0.56
Time: for (std::vector<Fred>::iterator i = vec.begin(); i < theEnd ; i++) { (*i).inc(); } 0.27
Time: std::for_each(vec.begin();vec.end(),std::mem_fun_ref(&Fred::inc)) 0.6
Time: for (size_t i = 0; i < theSize ; i++) { vec[i].inc(); } 0.27
Best regards,
Ta,
Avi