#include #include #include #include #include using std::cout; using std::endl; using std::vector; using std::function; using std::transform; using std::back_inserter; typedef function FunType; vector A = {sin, cos, tan, [](double x) { return x*x*x; } }; vector B = {asin, acos, atan, [](double x) { return exp(log(x)/3); } }; template function compose(function f, function g) { return [f,g](A x) { return f(g(x)); }; } int main() { vector composedFuns; auto exNums = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}; transform(B.begin(), B.end(), A.begin(), back_inserter(composedFuns), compose); for (auto num: exNums) for (auto fun: composedFuns) cout << u8"f\u207B\u00B9.f(" << num << ") = " << fun(num) << endl; return 0; }