fork download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5. template<typename...Ts>
  6. struct are_same;
  7.  
  8. template<typename T, typename U, typename...Ts>
  9. struct are_same<T, U, Ts...>
  10. {
  11. static const int value = is_same<T, U>::value && are_same<U, Ts...>::value;
  12. };
  13.  
  14. template<typename T>
  15. struct are_same<T>
  16. {
  17. static const int value = 1;
  18. };
  19.  
  20. int main()
  21. {
  22. cout << are_same<int, int, int, int>::value << endl;
  23. cout << are_same<int, double, int, int>::value << endl;
  24.  
  25. conditional<are_same<int, int, double>::value, int, double>::type a;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1
0