const double tolerance = 0.00001; bool CloseEnough (const double &val1 ,const double &val2) { return (abs(val1 - val2) < tolerance); } double FixedPoint (function<double (const double&)> f , const double &guess) { const auto next = f (guess); if (CloseEnough (guess, next)) { return next; } else { return FixedPoint (f, next); } } int main () { cout << FixedPoint ([] (const double &x) {return cos(x)+ sin(x);} , 1.0); cout << endl; return 0; }