Trivially Relocatable
summary
Argument: certain types can be treated as bitwise-movable so relocation becomes a single memcpy instead of move-then-destroy loops. Demonstration: compiler experiments on Godbolt/Compiler Explorer with Clang experimental P1144 and a custom attribute plus the trait std::is_trivially_relocatable, and microbenchmarks with Google Benchmark. Result: reallocating vectors of pointer-like types (unique_ptr/shared_ptr) becomes 3x faster in reserve-heavy scenarios by relying on memcpy relocation rather than element-wise moves.
AI-written summary · about
chapters (5)
- 0:00Intro
- 0:13Motivating "relocation"
- 1:44Relocating trivially copyable types
- 2:53Relocating non-trivial types
- 4:54Benchmark results
related talks
56mC++ Relocation - How to Achieve Blazing Fast Save and Restore and More!
24mMove Constructors: Is it Possible?
01h 06mThe Hidden Secrets of Move Semantics
01h 02mBack to Basics: C++ Move Semantics
01h 04mBack to Basics: Move Semantics
08mPolymorphic Task
06mLightning Talk: Writing a Better std::move
01h 03mTaming dynamic memory
