~/talk

Understanding The constexpr 2-Step

Talkat C++ on Sea 2024 · 2024-07-02..07-05· [compilers-and-language-design]
slides:none on file

Explains the constexpr two-step: generate dynamic data at compile time with constexpr new/delete, copy it into an oversized stack-style array, then create a right-sized static blob and return views (std::span or std::string_view). Demonstrates a 300-element angle table that compiles to 300 doubles but initially leaves 1,696 zeros of wasted capacity until right-sizing to capacity 512→300. Shows use of template non-type parameters to force static storage, prefers consteval + NTTP to catch errors, notes a Clang bug that elides static data inside consteval and gives mitigation.

AI-written summary · about

  1. 0:00Introduction
  2. 2:14Why this talk is challenging
  3. 3:02C++20 constexpr containers late arrival
  4. 4:08Using constexpr vector and string
  5. 7:46Compile-time memory allocation rules
  6. 10:58Introducing constexpr two-step
  7. 13:07Talk goals levels one-four
  8. 17:02Oversized array for compile-time storage
  9. 19:32Level one attempt one angles
  10. 22:25Level one attempt two binary size
  11. 27:02Level two string to constexpr string view
  12. 31:35Pitfalls with constexpr string views
  13. 36:15consteval to catch bugs early
  14. 38:04Builder pattern for dynamic ops
  15. 42:25Level 2.5 span and string view enhancements
  16. 48:51Right-sizing arrays avoiding bloat
  17. 51:41Right-sizing arrays compile-time sizes
  18. 57:00Level four vector of strings
  19. 1:00:13Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.