Fast Constraint Synthesis for C++ Function Templates
summary
A Clang frontend implements a lightweight interprocedural static analysis that encodes uses in a function body as constraints, composes them with conjunctions and disjunctions to model overloading, and applies a linear-time minimizer to keep synthesis fast. The tool processes 110k lines in <1.5s, synthesizes nontrivial constraints for 30–40% of function templates in STL algorithms and Boost special functions, and shortens compiler error output by about 56.6% and 63.8% respectively.
AI-written summary · about
chapters (9)
- 0:00Constraint synthesis for C++ templates
- 1:50Manual constraints in C++20 limits
- 3:17Three-step constraint synthesis
- 5:44Minimizing constraints fast
- 6:25Implementation on standard libraries
- 7:48Compiler error message length
- 9:16Speed versus precision trade-offs
- 10:17Conclusion and future work
- 11:02Q&A
related talks
27muser-defined statically-checked call graph constraints in C++
58mExploration of C++20 Meta Programming
01h 03m“Programming with C++ Constraints: Background, Utility, and Gotchas"
50mExpression Templates: Past, Present, Future
57mIntroduction to C++ Template Metaprogramming
01h 30mRethinking the Way We Do Templates in C++
55mCustom Overload Sets and Inline SFINAE for Truly Generic Interfaces
01h 00mC++ Function Templates: How Do They Really Work?
