is it possible to cast a variable to a templated subclass without knowing the template type? This is so that I can access a template property within the subclass. Here is some code and comments to help explain.
class base {...};
template <class T>
class sub_class : public base{
public:
T* /*or shared_ptr*/ value = nullptr;
};
int main() {
base* b = new sub_class<int>();
//I know b is a sub_class<int>,
//but is there any way I can cast it as a sub_class
//without knowing the that it took in an int
auto* s = (sub_class*)b;//This doesn't work but is
//there anything that does something similar to what
//I'm intending. Also, feel free to correct this
//line, I don't know much about using auto.
}
Any help is appreciated, including whether or not it's possible, any alternatives to what I want to achieve, etc. Thanks!