Fun With Type Erasure
summary
Demonstrates a C++ dispatcher that parses JSON requests (using tao::json) and maps fields or positional arrays to real function parameters with type checks, optional parameters, auto-generated textual descriptions, and detailed error messages. Implementation uses heavy templates, C++20 non-type string literal parameters for named args, byte-array/bit_cast storage to support pointer-to-member handlers, and reinterpret_cast only when safe; it compiles, runs, and can be made constexpr so handler tables initialize at compile time.
AI-written summary · about
chapters (12)
- 0:00Start
- 0:25What Is Stipulation
- 1:58Type Ratio of Functions
- 11:55Process Request Functions
- 23:25Validate Arguments Function
- 39:56Validation Function
- 44:17Use Optional Parameters
- 52:49Recap
- 54:55Type Raise Member Functions
- 1:04:48Default Constructor
- 1:09:38Aliases for Common Parameter Type
- 1:10:06What Can Be Done in the Future
related talks
01h 41mC++ Type Erasure Demystified
49mBack to Basics: Type Erasure
42mC++ Horizons
42mSerialization in C++ has never been easier! But wait, there's more
01h 02mCrafting EDSL In C++ using Metaprogramming, Operator Overloading, & Lambda Expressions
01h 13mType safe C++ – LOL! :-)
57mFun with Type Erasure: Implementing a Value Wrapper for Polymorphic Types
50mType safe C++? LOL!
