Pruning Error Messages From C++ Template Code
summary
A concrete recipe reduces 19 KB / 92 lines of GCC template noise down to two short messages for the SQL Plus+ embedded‑SQL library: hide templates behind inheritance, avoid recursive variadic meta‑recursions, prefer static_assert at API border, use static dispatch with run_check types to stop the compiler from droning on, and prefer checking rather than enable_if because GCC/Clang differ. Concepts lite looks promising but immature; the implemented approach compiles far faster and produces precise user‑facing errors.
AI-written summary · about
chapters (24)
- 0:00Reducing C++ template errors
- 1:09Template errors problems and expectations
- 3:38Clear error messages in templates
- 5:25Compiler differences in errors
- 6:53Avoid unnecessary templates
- 7:57Hide templates behind APIs
- 10:05Avoid recursion in templates
- 12:13Static assert for clear errors
- 14:25Static assert in functions
- 19:03Move static assert closer
- 20:48Limitations of enable_if
- 22:56Concepts Light for better errors
- 24:42Techniques summary
- 25:24Personal static assert strategy
- 31:29Static dispatch to prevent errors
- 34:02Collecting types for errors
- 37:17Final error message improvements
- 39:49Reducing errors to one message
- 41:38Key takeaways for developers
- 44:10Q&A: Deleted methods
- 45:33Q&A: Empty templates
- 46:42Q&A: Compiler error standards
- 48:07Q&A: Testing error messages
- 49:32Closing remarks
related talks
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
56mC++ Code Smells
51mSimplicity: Not Just for Beginners
05mCustomizing Compilation Error Messages Using C++ Concepts
01h 02mHow to Hide C++ Implementation Details
01h 11mPragmatic Simplicity - Actionable Guidelines To Tame Cpp Complexity
48mTooling Intuition
18mWriting Quality Code
