~/talk

Class Layout

Talkat Meeting C++ 2023 · 2023-11-12..11-14· [c-and-cpp]
links:none on file
slides:none on file

Shows concrete rules and experiments: use offsetof and compiler dumps (GCC/clang/MSVC flags, Godbolt) to see real offsets; C++11 loosens block ordering and C++23 mandates declaration order; apply no_unique_address or rely on EBCO to collapse empty members; composition can make an object 12 bytes versus 8 bytes — a 50% size difference — and microbenchmarks (Google Benchmark, 100 iterations, sizes 100..1e6) find layout-dependent timing with spikes and sometimes up to 4x speed differences for accumulate while results remain platform dependent and inconclusive.

AI-written summary · about

  1. 0:00Introduction
  2. 1:48Class layout in C++
  3. 3:35C++ standard layout rules
  4. 10:27Subobjects and layout
  5. 13:18Alignment requirements
  6. 17:01Inheritance vs composition
  7. 23:05Empty base class optimization
  8. 27:01Standard layout types
  9. 31:38Inspecting layout with compiler flags
  10. 39:17Performance impact of layout
  11. 49: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.