fork download
  1. #include<iostream>
  2. #include<type_traits>
  3.  
  4. template <typename ...Ts>
  5. struct types;
  6.  
  7. template <typename T, typename ...Ts>
  8. struct types < T, Ts... > : public types<Ts...>
  9. {
  10. template <typename F, int i = 0>
  11. struct find : public types<Ts...>::template find<F, i>
  12. {
  13. };
  14.  
  15. template <int i>
  16. struct find < T, i > : public std::true_type
  17. {
  18. typedef T type;
  19. };
  20. };
  21.  
  22. template <>
  23. struct types < >
  24. {
  25. template <typename F, int i = 0>
  26. struct find : public std::false_type
  27. {};
  28. };
  29.  
  30.  
  31. int main()
  32. {
  33. using namespace std;
  34. cout << types<int, char>::find<int>::value << endl;
  35. cout << types<int, char>::find<float>::value << endl;
  36. }
  37.  
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
1
0