fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. template<size_t depth, typename Func, typename... Args>
  7. auto deep(Func foo, Args&&... args)
  8. {
  9. if constexpr(depth != 0)
  10. {
  11. return foo(deep<depth-1>(foo, std::forward<Args>(args)...));
  12. }
  13. else
  14. return foo(std::forward<Args>(args)...);
  15. }
  16.  
  17. double Cos(double x) { return cos(x); }
  18.  
  19. int main(int argc, char * argv[])
  20. {
  21. cout << deep<100>(Cos,0.0);
  22. }
  23.  
Success #stdin #stdout 0s 5424KB
stdin
Standard input is empty
stdout
0.739085