Cute C++ Tricks (and what you can learn from them): Part 2 of N
summary
Part 2 unpacks concrete, reproducible surprises: using assert (not static_assert) inside constexpr functions, a template+lambda+concept trick to count aggregate members by constructing with objects convertible to anything, workarounds for copy/move overload ambiguity and move-only types, and a reflection-like destructure-to-callback that lets you serialize aggregates. A Google-used implementation has a bug. The session ends with the dangerous technique of stateful metaprogramming via friend injection and WG21’s unresolved plan to ban it.
AI-written summary · about
chapters (16)
- 0:00Introduction and goal
- 3:45Talk disclaimers and rules
- 5:50Understanding constexpr
- 10:44Ill-formed no diagnostic
- 13:15Assert in constexpr
- 15:58Constexpr in C++23
- 18:31Counting aggregate members
- 21:03Creating n copies
- 23:08Deducing template packs
- 27:49Fixing conversion issues
- 34:05Move-only type handling
- 38:27Disambiguation techniques
- 42:14Aggregate restrictions
- 45:31Metaprogramming reflection
- 47:33Stateful metaprogramming
- 54:48Conclusion and Q&A
related talks
32mCute C++ Tricks, Part 2 of N: More code you should learn from and never write
15mC++ WAT
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
59mModern C++ for Fun and Profit: This isn’t your old C++
01h 22mThese 10 tricks that only library implementors know!
01h 03mBack to Basics: Templates (part 2 of 2)
51mC++ Features You Might Not Know
01h 13mType safe C++ – LOL! :-)
