You may contact me if you have an STL solution...
Thanks to 'ofwolfandman':
#include <functional> #include <numeric> #include <utility> #include <vector> #include <boost/bind.hpp> int SumSecond(const std::vector<std::pair<int,int> >& v) { return std::accumulate( v.begin(), v.end(), static_cast<int>(0), boost::bind( std::plus<int>(), _1, boost::bind<int>(&std::pair<int,int>::second, _2) ) ); }
Thanks to 'ofwolfandman':