· 01:39
Antoine Morrier's article discusses a method for implementing type erasure in C++ without the use of macros, addressing criticisms of macro usage in programming. He presents a C++23-compliant solution that utilizes features such as deducing this
, along with structuring a lightweight and flexible type erasure system that allows for the definition of actions (like drawing) associated with different types (such as circles). The article details the design of a MethodTrait
to retrieve function signatures, hold function pointers, and properly invoke them. It highlights a dual storage pattern for the concrete type and function pointers, promoting a cleaner and more efficient coding experience while aiming for future optimizations.
deducing this
for more flexible function signatures.std::any
.std::any
.Listen to jawbreaker.io using one of many popular podcasting apps or directories.