What is SFINAE? How does it relate to template specialization?
Show answer and explanation
SFINAE means Substitution Failure Is Not An Error: when substitution fails in the immediate context of a function-template candidate, that candidate is removed from overload resolution instead of making the program ill-formed. It can enable overloads or partial class specializations conditionally, but it is not itself explicit specialization, and function templates cannot be partially specialized. In C++20, constraints and concepts usually express the same intent more clearly and produce better diagnostics.
SFINAE means Substitution Failure Is Not An Error: when substitution fails in the immediate context of a function-template candidate, that candidate is removed from overload resolution instead of making the program ill-formed. It can enable overloads or partial class specializations conditionally, but it is not itself explicit specialization, and function templates cannot be partially specialized. In C++20, constraints and concepts usually express the same intent more clearly and produce better diagnostics.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.