~/talk

C++14 Reflections Without Macros, Markup nor External Tooling..

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

A compile-time reflection technique for C++14 uses aggregate initialization probing plus variadic templates, constexpr, SFINAE, decltype and an implicit conversion operator to count fields and implicit conversion to capture field types, producing a std::tuple-like type map at compile time. It handles nested PODs (by flattening), const/volatile and multi-level pointers (encoding pointer bits into type IDs), and enums (by using their underlying type), and ships as apolukhin/magic_get (now pfr) on GitHub. It works and compiles fast (binary-search field detection); limitations include flattening, some loss of enum identity, and a reinterpret_cast workaround in C++14 that C++17 structured bindings can remove.

AI-written summary · about

  1. 0:00Introduction to reflection
  2. 1:06How magic_get works
  3. 3:15Counting fields in structures
  4. 7:36Detecting fields count implementation
  5. 10:04Extracting field types
  6. 12:59Encoding fundamental types
  7. 15:29Extracting field information
  8. 17:36Accessing fields by index
  9. 18:41Handling pointer types
  10. 21:36Encoding pointer types
  11. 23:21Handling nested structures
  12. 25:52Copying type identifiers
  13. 29:52Examples and use cases
  14. 31:19Comparison operators
  15. 32:41Serialization benefits
  16. 34:28Compile time performance
  17. 35:55Practical examples
  18. 37:44Flat tie function
  19. 38:47Fixing constexpr issues
  20. 39:50C++17 structured binding
  21. 41:37Conclusion and thanks
  22. 43:03Q&A: C++11 compatibility
  23. 44:06Q&A: Aggregate initialization
  24. 45:11Q&A: Reinterpret cast alternatives
  25. 46:39Q&A: Flattening limitations
  26. 48:30Q&A: Future of reflection
  27. 48:53Q&A: C++11 implementation details
  28. 49:58Q&A: Russian accent appreciation
  29. 50:20Q&A: Bit fields support
  30. 51:27Q&A: Nested structure layout
  31. 54:06Q&A: Function argument reflection
~/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.