Is it possible to have a templated class and also templating the constructor with some other type?
something like this:
template<typename T1>
class Foo{
template<typename T2>
Foo(T1 aBar, T2 dummyArgument){
bar = aBar;
bytesOfT2 = sizeof(T2);
};
int bytesOfT2;
T1 bar;
};
is this possible? and if so, how would I call such a constructor? Do I need to consider something in regards of header and cpp files?
thanks!
//edit: my particular example is actually even a little bit more complicated. i have
template <typename U1, U2>
class Foo{
U1 var1;
U2 var2;
};
template <typename T1>
class Bar{
template<typename T2, typename T3>
Bar(Foo<T2,T3> aFoo, T1 aVal){
val=aVal;
bytesOfT2=sizeof(T2);
bytesOfT3=sizeOf(T3);
};
int bytesOfT2;
int bytesOfT3;
T1 val;
};
does it mean i can here call the constructor just with any variable of type Foo and it should automatically select the proper Constructor acording to the particular version of Foo (for example if the variable i pass is of type Foo should it automatically set T2 to bool and T3 to float)?