Suppose I have the following code that I wish to refactor:
int toFuture() { precalc(); int calc = 5 * foobar_x() + 3; postcalc(); return calc; } int toP
One approach:
template int perform_calc(CalcFuncT&& calcfunc) { precalc(); int const calc = std::forward(calcfunc)(); postcalc(); return calc; } int main() { perform_calc([]{ return 5 * foobar_x() + 3; }); // toFuture perform_calc([]{ return 5 * foobar_y() - 9; }); // toPast }