C
cpunerd
I'm confused as to the syntax for partial template specialization.
Below is a very small example. Can someone tell me what I should do to
make this compile properly on an ISO-compliant compiler?
template <typename T1, typename T2>
class A
{
public:
T1 t1;
T2 t2;
};
template <typename T1, typename T2>
class B
{
public:
void insert(A<T1, T2> f);
};
template <typename T1>
void B<T1, int>::insert(A<T1, int> f)
{
f.t1 = 0;
f.t2 = 0;
}
template <typename T1, typename T2>
void B<T1, T2>::insert(A<T1, T2> f)
{
f.t1 = 0;
f.t2 = 0;
}
int main()
{
A<int, int> a1;
A<float, float> a2;
B<int, int> b1;
B<float, float> b2;
b1.insert(a1);
b2.insert(a2);
return 0;
}
Below is a very small example. Can someone tell me what I should do to
make this compile properly on an ISO-compliant compiler?
template <typename T1, typename T2>
class A
{
public:
T1 t1;
T2 t2;
};
template <typename T1, typename T2>
class B
{
public:
void insert(A<T1, T2> f);
};
template <typename T1>
void B<T1, int>::insert(A<T1, int> f)
{
f.t1 = 0;
f.t2 = 0;
}
template <typename T1, typename T2>
void B<T1, T2>::insert(A<T1, T2> f)
{
f.t1 = 0;
f.t2 = 0;
}
int main()
{
A<int, int> a1;
A<float, float> a2;
B<int, int> b1;
B<float, float> b2;
b1.insert(a1);
b2.insert(a2);
return 0;
}