~/talk

How To Use `constexpr` In C++23

Talkat NDC TechTown 2024 · 2024-09-09..09-12· [c-and-cpp]
slides:none on file

C++23 widens what can run at compile time and the rules matter: you cannot deallocate memory not allocated during constant evaluation, use reinterpret_cast, or rely on virtual inheritance, and many cmath trigonometric functions and thread/mutex/atomics remain non-constexpr in practice. Demonstrations show fixing a unique_ptr by adding a constexpr destructor, move ops and conditional noexcept so tests compile, using immediately-invoked constexpr lambdas and Catch2’s static_require compiled twice for runtime/compile-time parity, and building a compile-time scripting engine "consexer" and an ARM emulator that actually work at compile time.

AI-written summary · about

  1. 0:00Introduction to constexpr
  2. 1:55Rules and limitations
  3. 8:17History of constexpr
  4. 12:11Why use constexpr
  5. 14:46Building constexpr unique_ptr
  6. 27:14Legacy code to constexpr
  7. 33:37Virtual inheritance limits
  8. 35:45Real-world constexpr examples
  9. 45:37Stdlib constexpr limits
  10. 57:00Adopting constexpr in C++23
  11. 59:28Q&A
~/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.