Explicit Specialization of Function Templates Help
why would I need it if I could just make a non template function? I'm confused.
Because a non=template function cannot overload a template function.
If you do that you will not get the expected output if you explicitly choose to call the template function.
template <class T>
bool foo(T value)
bool foo(int value)
std::cout << foo(5) << std::endl;
std::cout << foo<>(5) << std::endl;
std::cout << foo<int>(5) << std::endl;
Most people would expect that these three function calls give the same result.
> why would I need it if I could just make a non template function? I'm confused.
In general, specializing a function template is a bad idea; prefer providing non-template overloads of the function instead.
This was discussed in this thread: http://www.cplusplus.com/forum/beginner/100227/
Topic archived. No new replies allowed.