13 Asynchronous model [async]

13.2 Requirements [async.reqmts]

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

13.2.7.11 Allocation of intermediate storage [async.reqmts.async.alloc]

Asynchronous operations may allocate memory. [ Note: Such as a data structure to store copies of the completion_handler object and the initiating function's arguments.  — end note ]

Let Alloc1 be a type, satisfying the ProtoAllocator ([async.reqmts.proto.allocator]) requirements, that represents the asynchronous operation's default allocation strategy. [ Note: Typically allocator<void>.  — end note ] Let alloc1 be a value of type Alloc1.

A completion handler object of type CompletionHandler has an associated allocator object alloc2 of type Alloc2 satisfying the ProtoAllocator ([async.reqmts.proto.allocator]) requirements. The type Alloc2 is associated_allocator_t<CompletionHandler, Alloc1>. Let alloc2 be a value of type Alloc2 obtained by performing get_associated_allocator(completion_handler, alloc1).

The asynchronous operations defined in this document:

  • If required, allocate memory using only the completion handler's associated allocator.

  • Prior to completion handler execution, deallocate any memory allocated using the completion handler's associated allocator.

Note: The implementation can perform operating system or underlying API calls that perform memory allocations not using the associated allocator. Invocations of the allocator functions do not introduce data races (see C++ 2014 [res.on.data.races]).  — end note ]