...or to quickly change types inside std::variant in source code.
Below is the code inside header files for the list itself and its container-element.
// HVector.hh
class HVector: public std::vector<HVElem>
{
public:
HVector();
void push(std::variant<Party, Loot> newData);
void show();
};
//HVElem.hh
class HVElem
{
public:
HVElem( std::variant<Party, Loot> newData );
~HVElem();
std::variant<Party, Loot> getData();
private:
std::variant<Party, Loot> data;
};
I'm worried that when I have to change the set of types that HVector can take I'll have manually go through a lot of code changing contents inside "<>" of each std::variant.
- Is this just a bad idea of using
std::variantin this case? - If yes, should I use templates or
std::any? - Is there a way to store types and pass them into
HVectorduring initialization? - Are refactoring tools a solution to the problem?