I have a short and easy challenge: come up with a way to implement a templated function that can accept a template parameter of 'void' and use it somehow, and still be valid syntax. You may not use pointers or casting, and, to make the challenge more obvious, the function should return a const char *. Hopefully you won't have a hard time typeing it out.
EDIT: I think that I was misunderstood...scroll down for the solution or don't scroll down to try and figure it out yourself.
@Computerquip Well what if the template argument represents the type of argument to be passed to a function? You might want to signify that no argument should be passed. I imagine one would usually want to specialise this case.
@LB I'm not sure if this matches your requirements, but when I had this problem, I did the following.
A contrived example, I know, but it illustrates the point.
I'm not quite sure what you want with the whole 'return const char* const' thing. Surely the content of the templated function is not relevant. Perhaps I have missed the point.
1 2 3 4 5
template <class S> constchar* const fn()
{
// yes, I'm returning the address of a temporary. what of it? :O
return"erm, I'm not sure what the whole 'return const char*' thing was about";
}