From SO:
What's the difference between result_of<F(Args…> and decltype<f(args…)>?
I see that
std::asyncis 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_ofis preferable to the use ofdecltype? (I understand thatresult_ofworks with types, whiledecltypeworks with expressions.)

Add a Comment
Comments are closed.