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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

io_context::wrap

(Deprecated: Use bind_executor.) Create a new handler that automatically dispatches the wrapped handler on the io_context.

template<
    typename Handler>
unspecified wrap(
    Handler handler);

This function is used to create a new handler function object that, when invoked, will automatically pass the wrapped handler to the io_context object's dispatch function.

Parameters

handler

The handler to be wrapped. The io_context will make a copy of the handler object as required. The function signature of the handler must be:

void handler(A1 a1, ... An an);

Return Value

A function object that, when invoked, passes the wrapped handler to the io_context object's dispatch function. Given a function object with the signature:

R f(A1 a1, ... An an);

If this function object is passed to the wrap function like so:

io_context.wrap(f);

then the return value is a function object with the signature

void g(A1 a1, ... An an);

that, when invoked, executes code equivalent to:

io_context.dispatch(boost::bind(f, a1, ... an));

PrevUpHomeNext