I think I understand by now why partial function templates are considered confusing and unnecessary, and are thus not allowed by the C++ standard. I would however appreciate some help with re-phrasing the following function w/o partial specialization. FWIW, the function is a member of a non-specialized class:
template <typename IMPL, typename RET>
RET call (functor <IMPL> func,
IMPL * impl)
{
return func.call (impl);
}
template <typename IMPL>
void call <IMPL, void_t> (functor <IMPL> func,
IMPL * impl)
{
func.call (impl);
}
The problem here is that I can't overload on the function's return type. Also, the typename I want to specialize on is not used as function parameter - another reason why overloading does not help. Yes, I could introduce a dummy parameter, to force overloading, but that is ugly, isn't it?
Finally, why the heck isn't 'void' a type in C++? That would make things so much more consistent... But I am probably missing the complete picture...
I believe that, firstly, if you have a function that returns void, then it's perfectly legitimate to return
a void expression- such as the call of another function that returns void, and secondly, void
is a full type in C++ and you can pass it to templates as much as you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With