fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Z { };
  5. template<class> struct Y { };
  6.  
  7. template<template <class> class... T>
  8. struct X
  9. {
  10. #if defined(__clang__)
  11. static const constexpr size_t count = sizeof...(T); // Clang
  12. #elif defined(_MSC_VER)
  13. static const size_t count = sizeof...(T); // MSVC 2013 - same as Clang
  14. #elif defined(__GNUC__)
  15. static const constexpr size_t count = sizeof...(T<Z>); // GCC (can be any valid template argument)
  16. #endif
  17. };
  18.  
  19. int main()
  20. {
  21. // should output 0 and 2
  22. cout << X<>::count << endl;
  23. cout << X<Y,Y>::count << endl;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0
2