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

Why does the call `f(0)` below select the SECOND overload, and what is the underlying rule that makes the first a non-error rather than a hard compile failure?

template <class T> auto f(T t) -> decltype(t.foo(), void()) { /* #1 */ } template <class T> void f(T) { /* #2 */ } f(0); // T deduced as int