fork(2) download
  1. #include <iostream>
  2.  
  3.  
  4. template <typename T, typename ...Ts>
  5. struct Foo {
  6. template <typename ...Us>
  7. static void bar(T& oT0, T& oT1, const T& iT0, const T& iT1, Us... args) {
  8. std::cout << " -> Foo<...>::bar() enter [ " << oT0 << ", " << oT1 << " ]" << std::endl;
  9. Foo<T>::bar(oT0, oT1, iT0, iT1);
  10. Foo<Ts...>::bar(args...);
  11. std::cout << " <- Foo<...>::bar() exit [ " << oT0 << ", " << oT1 << " ]" << std::endl;
  12. }
  13. };
  14.  
  15. template <typename T>
  16. struct Foo<T> {
  17. static void bar(T& oT0, T& oT1, const T& iT0, const T& iT1) {
  18. std::cout << " -> Foo<>::bar() enter [ " << oT0 << ", " << oT1 << " ]" << std::endl;
  19. oT0 = iT0;
  20. oT1 = iT1;
  21. std::cout << " <- Foo<>::bar() exit [ " << oT0 << ", " << oT1 << " ]" << std::endl;
  22. }
  23. };
  24.  
  25.  
  26. int main() {
  27. int i0 = -1,
  28. i1 = 0;
  29. float f0 = -97.18f,
  30. f1 = 3.141592f;
  31. std::cout << "( "<< i0 << ", " << i1 << "; " << f0 << ", " << f1 << " ) " << std::endl;
  32.  
  33. Foo<int, float, int>::bar(i0, i1, 0, 1, f0, f1, 18.f, -7.f, i0, i1, 4, 17);
  34. std::cout << "( "<< i0 << ", " << i1 << "; " << f0 << ", " << f1 << " ) " << std::endl;
  35.  
  36. Foo<float>::bar(f0, f1, 18.f, -7.f);
  37. std::cout << "( " << f0 << ", " << f1 << " ) " << std::endl;
  38.  
  39. Foo<float, int>::bar(f0, f1, 2.71f, 9000.1f, i0, i1, 4, 17);
  40. std::cout << "( "<< i0 << ", " << i1 << "; " << f0 << ", " << f1 << " ) " << std::endl;
  41.  
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
( -1, 0; -97.18, 3.14159 ) 
 -> Foo<...>::bar() enter [ -1, 0 ]
 -> Foo<>::bar() enter [ -1, 0 ]
 <- Foo<>::bar() exit [ 0, 1 ]
 -> Foo<...>::bar() enter [ -97.18, 3.14159 ]
 -> Foo<>::bar() enter [ -97.18, 3.14159 ]
 <- Foo<>::bar() exit [ 18, -7 ]
 -> Foo<>::bar() enter [ -1, 0 ]
 <- Foo<>::bar() exit [ 4, 17 ]
 <- Foo<...>::bar() exit [ 18, -7 ]
 <- Foo<...>::bar() exit [ 0, 1 ]
( 0, 1; -97.18, 3.14159 ) 
 -> Foo<>::bar() enter [ -97.18, 3.14159 ]
 <- Foo<>::bar() exit [ 18, -7 ]
( 18, -7 ) 
 -> Foo<...>::bar() enter [ 18, -7 ]
 -> Foo<>::bar() enter [ 18, -7 ]
 <- Foo<>::bar() exit [ 2.71, 9000.1 ]
 -> Foo<>::bar() enter [ 0, 1 ]
 <- Foo<>::bar() exit [ 4, 17 ]
 <- Foo<...>::bar() exit [ 2.71, 9000.1 ]
( 0, 1; 2.71, 9000.1 )