++namedtuple - Python-style Named Tuples in C++20
summary
Shows a concrete C++20 library that reproduces Python-style named tuples: implements namedtuple{"price"_t = 42, "size"_t = 1'000} and name tags like "price"_t via user-defined literals and non-type template parameters (std::fixed_string), uses Concepts, new lambda features and UDLs, and provides operator[] lookup, structure-bindings by specializing std::tuple_size/tuple_element and get, JSON printing, and composition. Implementation is ~100 lines of TMP, it compiles and runs, and benchmarks show roughly a single-digit-to-~20% compile-time cost versus std::tuple.
AI-written summary · about
chapters (20)
- 0:00Start
- 1:31Agenda
- 11:26Json
- 13:42Raw Polymorphism
- 17:38Named Tuple
- 19:56Udl Approach
- 20:33Fixed String Implementation
- 20:46Implementation
- 25:06Name Tuple and Multiple Parameters
- 26:32Implement the Get by Name
- 30:40The Raw Polymorphism
- 32:09What Is Not Working
- 35:47Implement the Get
- 37:26Structure Bindings
- 37:47Function Expressions
- 38:55Printing the Tuple
- 39:56Packed Name Tuple
- 40:45Questions
- 44:22Json Implementation
- 52:02Debug Version
related talks
06mLightning Talk: C++20 - A New Way of Meta-Programming?
01h 03mTemplate-less Metaprogramming in C++
06mLightning Talk: Can't we Just Synthesize std::tuple_element From Get?
01h 03mTemplates Made Easy with C++20
05mLightning Talks: -std=c++20 -- Will This C++ Code Compile?
07mLightning Talk: Higher-Order Template Metaprogramming with C++23
01h 04mC++ Concepts
01h 01mBack to Basics: Concepts in C++
