Great C++ is_trivial: trivial type traits
summary
Claim: knowing the exact is_trivially_destructible and trivially copyable rules makes performance questions about moves and copies moot. Shows concrete examples (return by value vs move, structured bindings, pass-by-value vs pass-by-move), inspects compiler output (assembly/Godbolt) and notes compilers since 1998 perform RVO while debug builds may still call move unless compilers treat move as builtin. Measures allocations (typical growth yields ~3 allocations), and recommends rule of zero and preferring trivial types.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 3:41Return value optimization and trivial types
- 12:35Pass by value vs move
- 24:17Trivial destructibility
- 29:35Trivial copyability and constructibility
- 40:44Defining trivial types
- 47:09Trivial efficiency best practices
- 56:03Rule of Zero benefits
- 57:50Q&A
related talks
54mA Tour of C++ Recognised User Type Categories
52mClasses C++23 Style
59mCute C++ Tricks, Part 2.5 of N - Code You Should Learn From & Never Write
01h 10mType Deduction and Why You Care
01h 03mBack to Basics: Declarations in C++
01h 04mBack to Basics: Object-Oriented Programming in C++
01h 01mConcepts vs Typeclasses vs Traits vs Protocols
01h 03mTemplate Metaprogramming: Practical Application
