From SO:
What's the difference between result_of<F(Args…> and decltype<f(args…)>?
I see that
std::async
is specified as follows:template <class F, class... Args> // copied out of the standard future<typename result_of<F(Args...)>::type> async(F&& f, Args&&... args);I had expected it to be declared like this:
template <class F, class... Args> auto async(F&& f, Args&&... args) -> future<decltype(f(forward<Args>(args)...)>;Would that be equivalent, or is there some way in which the use of
result_of
is preferable to the use ofdecltype
? (I understand thatresult_of
works with types, whiledecltype
works with expressions.)
Add a Comment
Comments are closed.