~/talk

How to test static_assert?

Talkat CppCon 2016 · 2016-09-18..09-23· [testing, compilers-and-language-design]
links:none on file
slides:none on file

Shows a concrete pattern that makes compile-time checks testable by ripping the condition out of static_assert into a type that either fires unconditionally or is harmless, then using tag dispatch plus a failure-return type (implemented as small rep_static_assert structs generated by a macro). Applied to sqlpp11 (≈100 static_asserts), this lets one-line compile-time tests live in a single file instead of thousands of failing-compile files, works around divergent Clang/GCC/MSVC diagnostics, and remains compatible with C++17 features like if constexpr and concepts.

AI-written summary · about

  1. 0:00Start
  2. 0:21Kiss Templates
  3. 5:39Basic Approaches
  4. 9:35Blending Diagnostic Messages
  5. 15:35Tag Dispatch
  6. 19:06Determining the Return Type Automatically
  7. 20:30Testing the Static Assert
  8. 28:15Return Type
  9. 32:48Summary
  10. 41:28Testability
  11. 42:27Compiler Generated Return Type
~/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.