Wrap up
Explore the fundamental concepts of std::variant in C++17 to grasp how it safely holds multiple alternative types without extra memory allocation. Understand how to access contained values, check active types, and use visitors for polymorphic operations.
We'll cover the following...
We'll cover the following...
Things to remember
Here are the things to remember about std::variant:
-
It holds one of several alternatives in a type-safe way
-
No extra memory allocation is needed. The variant needs the ...