Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++template metaprogrammingSingle-choice MCQ

In this SFINAE-based detection idiom, why does the primary template get selected for `has_type<int>` while the specialization is chosen for `has_type<Wrapper>`?

template <class T, class = void> struct has_type : std::false_type {}; template <class T> struct has_type<T, std::void_t<typename T::type>> : std::true_type {}; struct Wrapper { using type = int; }; // has_type<int>::value, has_type<Wrapper>::value