No templates (not even class templates) are types; type casting fundamentally cannot do this.
If you want to typecast an expression to a particular instantiation of a class template, this is possible, e.g.:
1 2 3 4 5 6 7
template <typename T>
class A { T i; };
struct B { explicitoperator A<int>() const { return A<int>{}; } };
int main() {
B my_b;
static_cast<A<int>>(my_b);
}
I have a string that is composed by an unknowed number of template variables and i want to store them.
I tried to divide the string and to cast each part but i am not able to do this.
Is there any way to avoid the cast?
thank you for your time :-)