The helper functions for binding associations to completion handlers, such as bind_executor, did not previously respect the value-category of wrapper. Consequently, when using move-only values with certain completion-handlers, build failures result since although the wrapper was an r-value, the wrapped target was not treated as such.
Changes
The solution is to forward the value-category of the wrapper to the wrapped target. This is already done in other wrappers in asio, like append. For these bind wrappers, an overload of their forwarding call operator is added to each wrapper. Moving the target is in C++03 form, using static_cast over std::move, to remain consistent with the rest of asio.
Failing Example
Although contrived, this example fails to build because the move-only completion handler Intermediary is not handled properly by bind_allocator. I've hit this build failure in multiple more realistic scenarios, particularly when using asio::awaitable, where the result of the awaitable frame cannot be allocated here due to the improper value-category.
Issue
The helper functions for binding associations to completion handlers, such as
bind_executor
, did not previously respect the value-category of wrapper. Consequently, when using move-only values with certain completion-handlers, build failures result since although the wrapper was an r-value, the wrapped target was not treated as such.Changes
The solution is to forward the value-category of the wrapper to the wrapped target. This is already done in other wrappers in asio, like append. For these bind wrappers, an overload of their forwarding call operator is added to each wrapper. Moving the target is in C++03 form, using
static_cast
overstd::move
, to remain consistent with the rest of asio.Failing Example
Although contrived, this example fails to build because the move-only completion handler
Intermediary
is not handled properly bybind_allocator
. I've hit this build failure in multiple more realistic scenarios, particularly when usingasio::awaitable
, where the result of the awaitable frame cannot be allocated here due to the improper value-category.