Skip to content

Latest commit

 

History

History
 
 

variant

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Variants

Here we explore:

  • how std::variant offers an alternative to inheritance.

Prerequisites

  • slides about std::variant
  • slides about lambda functions (for solution2)

Instructions

In the file variant.cpp, replace inheritance with the use of a std::variant. Two solutions are provided :

  1. with std::get_if,
  2. with std::visit.