fork download
  1. #include <iostream>
  2.  
  3. template<int, int>
  4. struct G1
  5. {
  6. G1()
  7. {
  8. std::cout << "G1\n";
  9. }
  10. };
  11.  
  12. template<int, int>
  13. struct G2
  14. {
  15. G2()
  16. {
  17. std::cout << "G2\n";
  18. }
  19. };
  20.  
  21. template<template<int, int> class T>
  22. struct Foo
  23. {
  24. T<7, 42> M;
  25. };
  26.  
  27. template<bool Condition, template<int, int> class T, template<int, int> class U>
  28. struct Conditional_asfdlol
  29. {
  30. template<int A, int B>
  31. struct Type : public T<A, B>
  32. {
  33. };
  34. };
  35.  
  36. template<bool Condition, template<int, int> class T, template<int, int> class U>
  37. struct Conditional_camper
  38. {
  39. template<int A, int B>
  40. struct Apply
  41. {
  42. typedef U<A,B> Type;
  43. };
  44. };
  45.  
  46. int main()
  47. {
  48. Foo<G1> F1;
  49. Foo<G2> F2;
  50.  
  51. Foo<Conditional_asfdlol<true, G1, G2>::Type> F3;
  52. Foo<Conditional_camper<false, G1, G2>::Apply> F4; // Nicht das gewünschte Ergebnis
  53. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
G1
G2
G1