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

What is wrong with this attempt to detect whether T has a `.size()` member using SFINAE in the function's return type?

template <typename T> auto has_size(T& t) -> decltype(t.size(), std::true_type{}) { return {}; } std::false_type has_size(...);