Title
task<...>::promise_type supports arbitrary allocator_arg position
Status
new
Section
[task.promise]
Submitter
Dietmar Kühl

Created on 2025-08-31.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-08-31.00:00:00

Normally the allocator_arg argument has to be the first argument when present. For task<...>::promise_type the allocator_arg can appear at an arbitrary position (except the last because it always needs to be followed by the allocator). This permission is inconsistent and the position of the allocator_arg argument and the allocator should be limited to come first.

For containers the optional support for allocators is implemented once for every container. For coroutines the optional support for allocators is implemented once for every coroutine definition. To support an optional allocator the coroutine definition needs to use an allocator and either gets duplicated not using an allocator or a forwarding function is added which adds the default allocator. With the flexible allocator position optional allocator support can be provided using a trailing argument list, i.e., adding , auto&&.... Instead of constraining task it may be more reasonable to add the flexibility to generator.

History
Date User Action Args
2025-08-31 00:00:00admincreate