I a trying to make a std::variant that can contain a vector of the same variant:
class ScriptParameter;
using ScriptParameter = std::variant<bool, int, double, std::string, std::vector<ScriptParameter> >;
I am getting ScriptParameter redefinition. It think it is possibly because a template parameter cannot be forward declared?
Is there a way to achieve a variant that could also contain an array of same typed variants?
Since the forward declaration says
ScriptParameter
is a class, you can't useusing
alias. However, nothing is inherently wrong here, sincevector
is only a pointer, there is no real circular dependency.You can use inheritance: