Constrained templates – the best practices
We have recommended the most useful SFINAE and concept-based techniques as we encountered them throughout the chapter, but we had a lot of material to cover, so it may be helpful to concisely restate these guidelines. These guidelines are here mainly for a programmer who uses templates in their application code. That includes the foundational code such as core template libraries of the applications, but a programmer writing a library such as STL, written for the widest possible use under extremely varied conditions and documented very precisely in a formal standard, would find these guidelines lacking in precision and formality:
- Learn the basic rules of SFINAE: in which contexts it applies (declarations) and in which it does not (function body).
- The “natural” use of SFINAE that arises from using parameter-dependent types in the template declarations and argument-dependent expressions in the trailing return...