why declare a explicit specialization? anyway it would be generated from template

why bother declare one, anyway the template would generate one base on the type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
template <class T>
void Swap (T &, T &); // template prototype
template <> void Swap<job>(job &, job &); // explicit specialization for job
int main(void)
{
template void Swap<char>(char &, char &); // explicit instantiation for char
short a, b;
...
Swap(a,b); // implicit template instantiation for short
job n, m;
...
Swap(n, m); // use explicit specialization for job
char g, h;
...
Swap(g, h); // use explicit template instantiation for char
...
}
Topic archived. No new replies allowed.