A
Alex Vinokur
When is it necessary to use template function instantiation?
template<typename T> void foo(T) { }
template void foo<int> (int); // Instantiation with the explicitly
specified template.
template void foo(char); // Instantiation with the deduced
template argument 'char'.
template void foo(double d) // Specialization
{
// Specialization
}
int main()
{
foo(123); // int
foo ('a'); // char
foo (3.14); // double - specialization
foo (std::string());
return 0;
}
What is the difference here between calling foo(123), foo (3.14), foo
(std::string()) ?
Thanks,
Alex .
template<typename T> void foo(T) { }
template void foo<int> (int); // Instantiation with the explicitly
specified template.
template void foo(char); // Instantiation with the deduced
template argument 'char'.
template void foo(double d) // Specialization
{
// Specialization
}
int main()
{
foo(123); // int
foo ('a'); // char
foo (3.14); // double - specialization
foo (std::string());
return 0;
}
What is the difference here between calling foo(123), foo (3.14), foo
(std::string()) ?
Thanks,
Alex .