Anything can be a Constexpr if you try hard enough
summary
Shows a working constexpr implementation of std::array<T,0>::data() when T may not be default‑constructible, not just a theory. Starts from aligned char buffer and explains why reinterpret_cast and static_cast fail for constexpr or invoke UB, then uses Richard Smith’s union-with-bool-tag pattern to provide a constexpr constructor without default-constructing T. Fixes aggregate requirements by adding a container-wrapper-to-preserve-aggregate and exposes wrapper.T pointer as data, with code and slides on the CppCon 2019 repo.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:31THE PROBLEM
- 0:55THE SOLUTION
- 1:54WHY THE BOOL?
- 2:14THE CONSTEXPR SOLUTION
- 2:29THE FINAL PROGRAM
related talks
01h 03mUnderstanding The constexpr 2-Step
01h 03mOLD VERSION: Understanding The constexpr 2-Step
01h 04mconstexpr: Introduction
01h 00mconstexpr: Applications
01h 04m“Constant Fun"
01h 10m“constexpr ALL the Things!”
01h 18m“Variable Templates and Compile-Time Computation with C++14"
58mC++, Abstract Algebra and Practical Applications
