Removing Metaprogramming From C++, Part 1 of N: constexpr Function Params
summary
Proposes letting a function parameter be marked as constexpr so callers can pass compile-time values without templates, adds an is_constant_expression check and a maybe constexpr (overload tiebreaker) idea, shows concrete wins: tuple/array indexing with compile-time bounds, compile-time regex compilation, a bounded-integer API that becomes plain ints for callers, and easier perfect-forwarding of mixed compile/runtime args. Paper is on GitHub, EWG votes June: not merged for C++20 but 27–4 encourages more work, targeting C++23.
AI-written summary · about
chapters (12)
- 0:00Introduction to proposal
- 1:09Current constexpr mechanics
- 6:19The proposed features
- 9:21Design goals and philosophy
- 14:55Bridging templates and functions
- 21:07Simplifying library design
- 24:37Concrete use cases
- 30:46Limitations and performance
- 33:38Metaprogramming replacement
- 39:56Standardization progress
- 47:17Related C++20 features
- 52:13Syntax and conclusion
related talks
58mExploration of C++20 Meta Programming
01h 04mconstexpr: Introduction
01h 01m“How bad is Meta-Programming still today?"
01h 00mHow To Use `constexpr` In C++23
01h 09m“Compile-time programming and reflection in C++20 and beyond”
01h 08mC++ Metaprogramming: A Paradigm Shift
57mIntroduction to C++ Template Metaprogramming
55mTemplates Made Easy With C++20
