13 Asynchronous model [async]

13.2 Requirements [async.reqmts]

13.2.7 Requirements on asynchronous operations [async.reqmts.async]

13.2.7.12 Execution of completion handler on completion of asynchronous operation [async.reqmts.async.completion]

Let Args... be the argument types of the completion signature Signature and let N be sizeof...(Args). Let i be in the range [0, N). Let Ti be the ith type in Args... and let ti be the ith completion handler argument associated with Ti.

Let f be a function object, callable as f(), that invokes completion_handler as if by completion_handler(forward<T0>(t0), ..., forward<TN-1>(tN-1)).

If an asynchronous operation completes immediately (that is, within the thread of execution calling the initiating function, and before the initiating function returns), the completion handler shall be submitted for execution as if by performing ex2.post(std::move(f), alloc2). Otherwise, the completion handler shall be submitted for execution as if by performing ex2.dispatch(std::move(f), alloc2).