I am just learning to use std::variant
and I would like to declare a type list consisting of (in principle) arbitrarily many of my user defined types. I.e., something like
template<typename T>
struct MyType{
T x;
};
template<typename T, int N>
MyClass{
public:
MyType<T> y;
int z = N;
double w;
MyClass(double b){
w = b;
}
};
template<typename T>
using my_type_list = std::variant<
MyClass<T,1>, MyClass<T,289>, MyClass<T,13>, ...., MyClass<T,5001>
>;
template<typename T>
std::vector<my_type_list> my_big_list = {
MyClass<T,1> { 2.0 },
MyClass<T,1> { 3.0 },
MyClass<T,289> { 9.4 },
MyClass<T, 13> { 1.3 },
MyClass<T, 5001> {2.5},
MyClass<T, 5001> {3.2},
..... etc....
};
but where the integer N
can in principle be anything.
is there any way that this is possible?