I have following example:
struct Wrapper
{
virtual ~Wrapper()
{
}
template <typename U>
WrapperT<U> * clone()
{
return new WrapperT<U>(value); //will not work, because value is not known here
}
};
template <typename T>
struct WrapperT : Wrapper
{
explicit WrapperT(T v)
{
value = v;
}
T value;
};
and I want something like this:
Wrapper *t = new WrapperT<int>(1);
WrapperT<double> *t2 = t->clone<double>();
I know virtual templates are not available. Any ideas?