Modern C++ Interfaces: Complexity, Emergent Simplicity, SFINAE, and Second Order Properties of Types
Play Modern C++ Interfaces: Complexity, Emergent Simplicity, SFINAE, and Second Order Properties of Types
We examine how the increasing complexity of language features related to interfaces in modern C++ has somewhat surprisingly produced increasing simplicity in the interfaces themselves. One of the major reasons for this emergent simplicity is common use of “substitution failure is not an error” or SFINAE in interface design. Appropriate use of SFINAE allows the production of “do what I mean” or DWIM interfaces that allow experienced designers to embed their judgement in interfaces. Most of the presentation will consist in examination of practical examples of SFINAE in interface design and development of a simple toolkit that automates construction of compile time template predicates. Abstract syntax trees are evaluated at compile time to enforce complex constraints on types in the SFINAE context.