How do C++20 Concepts improve template error messages compared to SFINAE?
Last updated
Concepts are named requirement predicates, so a failure reports "constraint not satisfied" at the call site, naming the concept and requirement. SFINAE silently drops candidates, yielding vague "no matching function" errors deep in library code.
Constraints are declared readably via concept names and
requiresclauses, instead of being encoded instd::enable_ifanddecltypetricks.Concepts support subsumption (ordering constraints), avoiding the ambiguous overloads common with stacked
enable_if.