Concepts and constraints in C++20
The rest of this chapter is all about the “artificial” substitution failures that are added to the template declaration to impose restrictions on the template arguments. In this section, we are going to learn about the new, C++20, way of coding these restrictions. In the next section, we will show what you can do if you can’t use C++20 but still want to constrain your templates.
Constraints in C++20
C++20 changed the way we are using SFINAE to restrict template arguments by introducing concepts and constraints. Even though the overall feature is usually referred to as “concepts,” it is the constraints that are the most important part. What follows is not a complete or formal description of these features, but rather a demonstration of the best practices (it may be too early to say “patterns” since the community is still in the process of establishing what is and isn’t sufficiently widely...