fork download
  1. #include <cstdlib>
  2. #include <tuple>
  3.  
  4. template<typename X> struct Y {};
  5.  
  6. template<typename T, size_t Level, size_t TermLevel> struct A;
  7.  
  8. template<typename ... Ts>
  9. struct A<std::tuple<Y<Ts>...>, 1, 1> {};
  10.  
  11. // (B) dummy for T=tuple<int, Ts...> just to show it works for simple expansions
  12. template<typename ... Ts, size_t Level, size_t TermLevel>
  13. struct A<std::tuple<int, Ts...>, Level, TermLevel>
  14. {
  15. A<std::tuple<int, Ts...>, Level+1, TermLevel> value;
  16. };
  17.  
  18. template<typename ... Ts, size_t Level>
  19. struct A<std::tuple<int, Ts...>, Level, Level> {};
  20.  
  21.  
  22. // (C) ambiguous partial specialization
  23. template<typename T1, typename T2, size_t Level, size_t TermLevel>
  24. struct A<std::tuple<Y<T1>, Y<T2> >, Level, TermLevel>
  25. {
  26. A<std::tuple<Y<T1>, Y<T2>>, Level+1, TermLevel> value;
  27. };
  28.  
  29. template<typename T1, typename T2, size_t Level>
  30. struct A<std::tuple<Y<T1>, Y<T2>>, Level, Level> {};
  31.  
  32. int main(int argc, const char *argv[])
  33. {
  34. A<std::tuple<int, Y<int>, Y<float>>, 0, 5> tint;
  35. A<std::tuple<Y<int>, Y<float>>, 0, 5> tn;
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 2824KB
stdin
Standard input is empty
stdout

Standard output is empty