Tag: std::variant
3 posts
-
Design Patterns in Modern C++: What Singleton, Factory, Observer, Strategy and Visitor Look Like After C++17
How GoF patterns change in modern C++: Meyers singleton and its test traps, factory registries, observer re-entrancy, visitor as std::variant, CRTP.
-
C++ Visitor Pattern: Classic Double Dispatch vs std::variant and std::visit
Visitor pattern in modern C++: classic accept/visit vs std::variant + std::visit (C++17), ASTs, the expression-problem tradeoff between adding types and adding operations, and the pitfalls in each.
-
C++ std::variant vs union: Type Safety, Overhead and When to Use Each
std::variant vs union: how variant tracks the active type and dispatches with std::visit, what a raw union leaves to you, and migrating legacy unions.