Why Concepts vs SFINAE
Compare the readability of concepts with classical SFINAE techniques.
The SFINAE Era
Before C++20, constraining templates required SFINAE (Substitution Failure Is Not An Error). It worked but produced cryptic errors and verbose code.
A SFINAE Example
Restricting a function template to arithmetic types — pre-C++20.
template <typename T,
typename = std::enable_if_t<std::is_arithmetic_v<T>>>
T double_it(T x) {
return x * 2;
}