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

Why might `tag_invoke`-style or `if constexpr` dispatch be chosen over enable_if SFINAE for selecting between two implementations inside ONE function?

template <typename T> void serialize(const T& t) { if constexpr (has_to_json_v<T>) { /* A */ } else { /* B */ } }