#include <algorithm>
-#include <tr1/functional>
#include <numeric>
#include <iterator>
#include <sstream>
double cost_func::operator()(double amount) const
{
- using std::tr1::bind;
- using std::tr1::placeholders::_1;
- using std::tr1::placeholders::_2;
return std::accumulate(++factors.begin(), factors.end(), factors.front(),
- bind(std::plus<double>(),
- bind(std::multiplies<double>(), amount, _1),
- _2));
+ [&amount](double a, double b) {
+ return amount * a + b;
+ });
}
std::string cost_func::to_string()