“Type Traits - what are they and why should I use them?"
summary
Defines type traits as compile-time templates that return type info and shows concrete examples: is_floating_point and rank (array dimensionality), remove_const/_t aliases, and iterator_traits with five nested typedefs. Demonstrates SFINAE via enable_if to restrict overloads, walks through overload resolution outcomes, and explains vector push_back optimizations using noexcept(move) checks and trivially_copyable fast memcpy path. Mentions real pitfalls, performance tradeoffs, and sources for deeper reading.
AI-written summary · about
chapters (8)
- 0:00Introduction to Type Traits
- 1:14Why Use Type Traits
- 3:21Taxonomy of C++ Types
- 8:09Understanding Type Traits
- 13:17Type Traits in Algorithms
- 18:39Restricting Templates with SFINAE
- 31:23Optimization with Type Traits
- 40:48Q&A and Further Learning
related talks
01h 01mThe promise of static reflection in C++26: Type Traits without compiler intrinsics
57mIntroduction to C++ Template Metaprogramming
27mRe-inventing trait objects
01h 30mRethinking the Way We Do Templates in C++
01h 00mModern Template Metaprogramming: A Compendium, Part I
01h 27mC++20 Templates - the Next Level: Concepts and More
56m“Modern C++ Interfaces..."
01h 01mRethinking the Way We Do Templates in C++
