Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit b5c99c1c90.
PrevUpHomeNext

bind_front_handler

Bind parameters to a completion handler, creating a new handler.

Synopsis

Defined in header <boost/beast/core/bind_handler.hpp>

template<
    class Handler,
    class... Args>
implementation-defined
bind_front_handler(
    Handler&& handler,
    Args&&... args);
Description

This function creates a new handler which, when invoked, calls the original handler with the list of bound arguments. Any parameters passed in the invocation will be forwarded in the parameter list after the bound arguments. The passed handler and arguments are forwarded into the returned handler, whose associated allocator and associated executor will will be the same as those of the original handler.

Example

This function posts the invocation of the specified completion handler with bound arguments:

template <class AsyncReadStream, class ReadHandler>
void
signal_eof (AsyncReadStream& stream, ReadHandler&& handler)
{
    net::post(
        stream.get_executor(),
        bind_front_handler (std::forward<ReadHandler> (handler),
            net::error::eof, 0));
}
Parameters

Name

Description

handler

The handler to wrap. The implementation takes ownership of the handler by performing a decay-copy.

args

A list of arguments to bind to the handler. The arguments are forwarded into the returned object.


PrevUpHomeNext