M
MiniDisc_2k2
Okay I just came up with this scenario and wanted to know if it was
possible. Thus, this is extremely generic code and serves no practical
purpose:
template <class T, class N>
class A
{
// ... some members ...
void f(A<T,>) // is this possible?
};
template <class T, class N>
void A::f(A<T,> data)
{
// coding
}
In case you couldn't find out what I was doing, I was trying to allow the
template to access any type for the second type, like this:
int main()
{
A<int, char> a1;
A<int, float> a2;
a1.f(a2); // this is legal
a1.f(a1); // this is also legal
}
As you can see, the compiler doesn't worry about the type of the second
typename. Is there any way to do this? Or (now that I think about it) can
you make a template of a template?
possible. Thus, this is extremely generic code and serves no practical
purpose:
template <class T, class N>
class A
{
// ... some members ...
void f(A<T,>) // is this possible?
};
template <class T, class N>
void A::f(A<T,> data)
{
// coding
}
In case you couldn't find out what I was doing, I was trying to allow the
template to access any type for the second type, like this:
int main()
{
A<int, char> a1;
A<int, float> a2;
a1.f(a2); // this is legal
a1.f(a1); // this is also legal
}
As you can see, the compiler doesn't worry about the type of the second
typename. Is there any way to do this? Or (now that I think about it) can
you make a template of a template?