I'm trying to create an any struct, i.e. a struct that contains one of so many types. Here is my attempt so far:
template <typename Type, typename... Rest> struct OneOf {
union {
Type value;
OneOf<Rest...> rest;
};
};
template <typename Type> struct OneOf {
Type value;
};
Sadly, this doesn't compile. When I try to instantiate it, I get:
one_of.h:34:33: error: redeclared with 1 template parameter template struct OneOf {
Is there a way to terminate a self referencing recursion with structs?
Aucun commentaire:
Enregistrer un commentaire