Programming with C++ Constraints: Background, Utility, and Gotchas
Compile-time constraints will likely soon become part of our routine C++ programming vocabulary. Why? Such constraints are induced by new core language features (requires-clauses and requires-expressions) that are on the horizon for C++. What are these all about? Almost every function imposes requirements on its users; violating those requirements typically leads to incorrect programs. Historically, such requirements had to be expressed in comments or other documentation, as there was little machinery to express them in code. Soon we will be able to express more requirements in code, thus allowing compilers to detect and address more violations. This talk aims to prepare both new and veteran C++ programmers with the necessary background, tutorial information, and advice to exploit this powerful new supplement to function declarations. A case study, illustrating an unexpected gotcha, will conclude the presentation.