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
ScriptParameteris a class, you can't useusingalias. However, nothing is inherently wrong here, sincevectoris only a pointer, there is no real circular dependency.You can use inheritance: