Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++SFINAE and enable_ifSingle-choice MCQ

Why does putting `std::enable_if_t` as a defaulted template parameter work for constraining two otherwise-identical function templates, while the return-type form is preferred to avoid in constructors?

template <typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0> T g(T); template <typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0> T g(T);