Here we explore:
- how
std::variant
offers an alternative to inheritance.
- slides about
std::variant
- slides about lambda functions (for solution2)
In the file variant.cpp
, replace inheritance with the use of a std::variant
.
Two solutions are provided :
- with
std::get_if
, - with
std::visit
.