~/talk

Implementing static_vector: How Hard Could it Be?

Talkat CppCon 2021 · on Monday, 2021-10-25· at 16:45· B) Summit 8/9, online· [frontend-architecture]
links:none on file
slides:none on file

Stack-allocated static_vector claims std::vector semantics but with inline storage, and the talk drills into real tradeoffs: a size optimization that can be 18 vs 24 bytes (33% increase), why a stack allocator breaks value semantics, why raw byte storage needs alignas and an uninitialized array wrapper, the memcpy-null-pointer issue that forces a custom memcpy, how constexpr interacts with construct_at, and why relocation / trivially relocatable support and non-constant-time swap force API and standard changes to make a production-quality static_vector.

AI-written summary · about

  1. 0:00Start
  2. 0:26What Is Static Vector
  3. 3:40Parts of the Interface of Static Vector
  4. 5:18Size Optimization
  5. 6:29Storage of the Data
  6. 7:16Breaks Value Semantics
  7. 12:02Uninitialized Array
  8. 16:26Why Do I Have no Unique Address on the Member Variable
  9. 17:55Implicit Lifetime Types
  10. 27:03Proposal for C plus 23 To Make It Easier To Write Range Adapters
  11. 38:51Move Constructor
  12. 39:43Conditionally Trivial Special Member Functions
  13. 41:10Trivial Relocation
  14. 44:25Relocating Unique Pointer
  15. 49:23What Happens if Move Throws an Exception
  16. 50:28Swap
  17. 50:57Swap Static Vectors
~/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.