G
gao_bolin
I have the following situation:
class A
{
public:
virtual ~A() {}
};
template < typename T >
class B : public A
{
};
The problem is to find the template argument T when a function receives
only a pointer A* (and we know for sure that the A* indeed points to a
B<T>*).
One way is to dynamic_cast to a bunch of know B<T>, but this is kind of
heavy and works only for types that are explicitely taken into account.
Is there a way to retrieve type T for any T, and say print it out?
Thanks
Bolin
class A
{
public:
virtual ~A() {}
};
template < typename T >
class B : public A
{
};
The problem is to find the template argument T when a function receives
only a pointer A* (and we know for sure that the A* indeed points to a
B<T>*).
One way is to dynamic_cast to a bunch of know B<T>, but this is kind of
heavy and works only for types that are explicitely taken into account.
Is there a way to retrieve type T for any T, and say print it out?
Thanks
Bolin