13 Asynchronous model [async]

13.2 Requirements [async.reqmts]

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

13.2.7.2 Completion tokens and handlers [async.reqmts.async.token]

Initiating functions:

  • are function templates with template parameter CompletionToken;

  • accept, as the final parameter, a completion token object token of type CompletionToken;

  • specify a completion signature, which is a call signature (C++ 2014 [func.def]) Signature that determines the arguments to the completion handler.

An initiating function determines the type CompletionHandler of its completion handler function object by performing typename async_result<decay_t<CompletionToken>, Signature>::completion_handler_type. The completion handler object completion_handler is initialized with std::forward<CompletionToken>(token). [ Note: No other requirements are placed on the type CompletionToken.  — end note ]

The type CompletionHandler shall satisfy the requirements of Destructible (C++ 2014 [destructible]) and MoveConstructible (C++ 2014 [moveconstructible]), and be callable with the specified call signature.

In this document, all initiating functions specify a Completion signature: element that defines the call signature Signature. The Completion signature: elements in this document have named parameters, and the results of an asynchronous operation are specified in terms of these names.