I am not clear about the interaction of default template arguments in the context of partial specialization, for choosing which is the better matching template. This questions s
template >
struct cond : public bool_constant {};
is identical to
template > struct cond;
template
struct cond : public bool_constant {};
Later might be clearer to understand the result.
When you write cond, thanks to default argument, it is equivalent to cond.
Then we try to match that to "better instantiation".
We have the choice between:
// primary template
template
struct cond : public bool_constant {};
and partial specialization, which use SFINAE:
// specialization
template
struct cond> : public bool_constant {};
If 0 == T::code is ill formed, specialization is discarded and only primary template is a viable solution, so it is used.
Else if 0 == T::code evaluates to false, the specialization doesn't match and primary template is also used.
Note that using cond would use the specialization in that case.
Else, 0 == T::code evaluates to true, and then both primary and specialization are viable, but specialization is more specialized, so it is chosen.