Boost logo

Boost Users :

Subject: Re: [Boost-users] [Asio/Beast] Any non-obvious reasons for no bind_executor_and_allocator?
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2018-12-20 06:13:52


On Wed, Dec 19, 2018 at 9:37 PM Sorin Fetche <sorin.fetche_at_[hidden]> wrote:
> And this is what I have in mind:
> ...
> self.socket.async_read_some(
> read_buffer,
> asio::bind_executor(
> self.get_executor(),
> [self = std::move(self)](error_code ec, std::size_t bytes) mutable {
> if (!ec) {
> /* ... */
> } else {
> self.user_completion_handler(ec, bytes);
> }
> }));

I sense danger here. The order of evaluation of function arguments is
not defined. If the lambda is constructed first, then the call to
`self.get_executor()` will be performed on a moved-from object. I
could be wrong though...

Regards


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net