~/talk

The C++ Type System Is Your Friend

Talkat ACCU 2017 · 2017-04-24..04-29· [c-and-cpp]
links:none on file
slides:none on file

Argues C++ types and templates enforce domain rules with zero runtime cost: concrete examples include whole value pattern year/month/day wrappers, user‑defined literals, a units/quantity system that does compile‑time dimensional arithmetic (prevents mixes like meters vs feet and the Mars Climate Orbiter failure), and policy‑based fixed_string to handle truncation. Uses CRTP and CRTP base templates plus constexpr checks to move validation to compile time; clang -O3 emits identical assembly, GCC shows only minor differences. Concepts improve error messages.

AI-written summary · about

  1. 0:00Intro
  2. 0:55Safe, performant, reusable code
  3. 3:06(Mostly) typeless programming
  4. 6:20Machine-typed programming
  5. 8:47Type-rich programming
  6. 10:26The miracle of compilation Runtime
  7. 13:48Physical types
  8. 16:14Whole Value pattern
  9. 18:43Templates to the rescue
  10. 19:56Adding checking of values
  11. 25:46Reuse through client libraries
  12. 33:24Physical quantities and dimensions
  13. 35:31Tailoring operations - library code
  14. 37:12Tailoring operations - client code
  15. 39:47Templates and policies
  16. 42:38Implementing policies • Let's use a policy on overflow
  17. 44:18Constructor validation logic • Let's use a policy to enforce that quantities are non-negative
  18. 45:49Effect of constructor validation logic . So, what about the generated code?
  19. 46:49Starting to define a domain type . We have now restricted both the operations and the range of allowed values
  20. 47:32Domain types vs primitives • Business rules still exist when using primitives: they are just distributed
  21. 54:28Compile-time range calculation
  22. 55:21Scaling and errors • As systems get larger the number of possible combinations of types (and therefore incompatibilities) grows even faster
  23. 56:39Templates and "concepts lite"
  24. 59:15Concepts code - first attempt
~/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.