fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename...T> struct check;
  5. template<typename A, typename...B> struct check<A,B...> {
  6. static constexpr bool pass = check<B...>::pass;
  7. };
  8. template<typename...R> struct check<int,char,bool,R...> {
  9. static constexpr bool pass = true;
  10. };
  11. template<> struct check<> {
  12. static constexpr bool pass = false;
  13. };
  14.  
  15. template<typename... T>
  16. constexpr bool checkTO(T...) { return check<T...>::pass; }
  17.  
  18.  
  19.  
  20. int main()
  21. {
  22. int a = 1;
  23. char b = 'c';
  24. bool c = true;
  25. float d = 1.1;
  26. float d1 = 1.1;
  27. float d2 = 1.2;
  28.  
  29. std::cout << "TRUE1: " << checkTO() << std::endl;
  30. std::cout << "TRUE1: " << checkTO(a, b, c) << std::endl;
  31. std::cout << "TRUE2: " << checkTO(a, a, b, c) << std::endl;
  32. std::cout << "TRUE3: " << checkTO(a, a, b, c, c) << std::endl;
  33. std::cout << "TRUE4: " << checkTO(d, a, b, c, c) << std::endl;
  34. std::cout << "TRUE5: " << checkTO(a, b, d1, a, b, c, d2) << std::endl;
  35. std::cout << "TRUE6: " << checkTO(d1, d2, a, a, a, b, c) << std::endl;
  36. std::cout << "TRUE7: " << checkTO(a, b, c, d1, d2, a, a, b, a, c) << std::endl;
  37. std::cout << "FALSE1: " << checkTO(c, a, b) << std::endl;
  38. std::cout << "FALSE2: " << checkTO(b, c, a) << std::endl;
  39. std::cout << "FALSE3: " << checkTO(d1, a, b) << std::endl;
  40. std::cout << "FALSE4: " << checkTO(a, b, d1, c) << std::endl;
  41.  
  42. }
Success #stdin #stdout 0s 4348KB
stdin
Standard input is empty
stdout
TRUE1: 0
TRUE1: 1
TRUE2: 1
TRUE3: 1
TRUE4: 1
TRUE5: 1
TRUE6: 1
TRUE7: 1
FALSE1: 0
FALSE2: 0
FALSE3: 0
FALSE4: 0