~/talk

Data in the Type System: Complex Non-Type Template Parameters in C++20

Talkat CppCon 2019 · 2019-09-15..09-20· [compilers-and-language-design]
links:none on file
slides:none on file

C++20 adds class-type NTTPs so class objects can be template arguments (removing the need for the non-standard "forbidden UDL"), with requirements: literal type, trivial destructor, strong structural equality, and the compiler emits an lvalue object into the binary for each distinct value. Practical pieces include a fixed_string type and a type-safe printf built with template-parsed format strings that compiles and works; compiler behavior varies (GCC/Clang earlier showed ~50 bytes per char and ~278 bytes per char for the raw UDL before optimizations), and some compilers still miss restriction checks.

AI-written summary · about

  1. 0:00Introduction
  2. 1:09Forbidden UDL and use cases
  3. 5:49Committee concerns and history
  4. 7:16Template vs function parameters
  5. 10:13Type-safe printf wrapper
  6. 18:45C++17 limitations
  7. 20:11Type equality and identity
  8. 27:25Class type NTT P behavior
  9. 31:16Fixed string in C++20
  10. 35:15User-defined literals with classes
  11. 39:54Caveats and future changes
  12. 40:39Memory usage benchmarks
  13. 45:48Compiler optimizations
  14. 46:54Updated printf example
  15. 50:00Q&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.