fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. typedef std::vector<unsigned> arguments;
  5. typedef unsigned nat;
  6.  
  7. template<typename F, typename... G>
  8. struct S {
  9.  
  10. static nat apply(arguments const & args) {
  11. arguments output = { G::apply(args)... };
  12. return F::apply(output);
  13. }
  14.  
  15. template<typename... T>
  16. static nat apl(T... x) {
  17. arguments args = { static_cast<nat>(x)... };
  18. return apply(args);
  19. }
  20. };
  21.  
  22. template<nat N, nat M>
  23. struct U {
  24.  
  25. static nat apply(arguments const & args) {
  26. return args[M - 1];
  27. }
  28.  
  29. template<typename... T>
  30. static nat apl(T... x) {
  31. arguments args = { static_cast<nat>(x)... };
  32. return apply(args);
  33. }
  34. };
  35.  
  36. struct N {
  37.  
  38. static nat apply(arguments const & v) {
  39. return v[0] + 1;
  40. }
  41.  
  42. template<typename... T>
  43. static nat apl(T... x) {
  44. arguments args = { static_cast<nat>(x)... };
  45. return apply(args);
  46. }
  47. };
  48.  
  49. int main() {
  50. std::cout << S<N, U<2, 1> >::apl(5, 3) << std::endl;
  51. return 0;
  52. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
6