fork download
  1. template<int I, class T>
  2. struct match_base{
  3. static int_<I> test(T);
  4. };
  5.  
  6. template<int Cur, class T, class... Us>
  7. struct match_bases
  8. : match_base<Cur, T>
  9. , match_bases<Cur+1, Us...>
  10. {
  11. using match_base<Cur, T>::test;
  12. using match_bases<Cur+1, Us...>::test;
  13. };
  14.  
  15. template<int I, class T>
  16. struct match_bases<I, T>
  17. : match_base<I, T>
  18. {
  19. using match_base<I, T>::test;
  20. };
  21.  
  22. template<class... Us>
  23. struct best_match_
  24. : match_bases<0, Us...>
  25. {
  26. using match_bases<0, Us...>::test;
  27.  
  28. template<class V>
  29. static auto test2(int) -> decltype(test(std::declval<V>()));
  30. template<class>
  31. static auto test2(...) -> int_<-1>;
  32. };
  33.  
  34. template<class T, class... Us>
  35. using best_match = decltype(best_match_<Us...>::template test2<T>(0));
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty