fork download
  1. #include <annex/meta.hpp>
  2. #include <annex/indices.hpp>
  3.  
  4. using annex::Int;
  5. using annex::indices;
  6. using annex::Indices;
  7. using annex::meta::list;
  8. using annex::Void;
  9.  
  10. template<typename C, int I>
  11. struct candidate {
  12. static Int<I> test(C);
  13. };
  14.  
  15. template<typename T, typename Candidates, typename Indices>
  16. struct best_match_impl {
  17. static Int<-1> test(...);
  18. };
  19.  
  20. template<typename T, typename C, typename... Cs, int I, int... Is>
  21. struct best_match_impl<T, list<C, Cs...>, indices<I, Is...>>
  22. : candidate<C, I>, best_match_impl<T, list<Cs...>, indices<Is...>> {
  23. using candidate<C, I>::test;
  24. using best_match_impl<T, list<Cs...>, indices<Is...>>::test;
  25. };
  26.  
  27. template<typename T, typename Candidates, typename Indices = Indices<Candidates::size::value>, typename Sfinae = void>
  28. struct best_match: Int<-2> {};
  29.  
  30. template<typename T, typename Candidates, typename Indices>
  31. struct best_match<
  32. T, Candidates, Indices
  33. , Void<decltype(best_match_impl<T, Candidates, Indices>::test(std::declval<T>()))>
  34. >
  35. : decltype(best_match_impl<T, Candidates, Indices>::test(std::declval<T>())) {};
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty