fork(2) download
  1. #include <utility>
  2.  
  3. template<template<typename,typename>class checker, typename... Ts>
  4. struct is_all : std::true_type {};
  5.  
  6. template<template<typename,typename>class checker, typename T0, typename T1, typename... Ts>
  7. struct is_all<checker, T0, T1, Ts...> :
  8. std::integral_constant< bool, checker<T0, T1>::value && is_all<checker, T0, Ts...>::value>
  9. {};
  10.  
  11. template<typename... Ts>
  12. using is_all_same = is_all< std::is_same, Ts... >;
  13.  
  14. #include <iostream>
  15.  
  16. int main() {
  17. std::cout << is_all_same<int, int>::value << is_all_same<double, double, int>::value << is_all_same<int, int, int, int, int>::value << "\n";
  18. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
101