When i am using
std::result_of<F(R)>
like this:
template<typename R, typename... Args>
class Task
{
//...
template<typename F>
auto Then(F&& f) -> Task<typename std::result_of<F(R)>::type(Args...)>
{
//...
}
};
Since R is another function's output type, so R may be void, in this situation, there will be:
error: invalid parameter type ‘void’.
So the question is how to handle both R is void and is not?
Option #1
SFINAE-based:
DEMO
Option #2
Partial-specialization of the class template:
DEMO 2
Option #3
Tag-dispatching:
DEMO 3