forked from boostorg/beast
control callback is copied or moved:
The function stream::control_callback now copies or moves the callback. In some cases this may require a dynamic allocation. To avoid the possibility of a dynamic allocation, callers may wrap their callback using `std::ref` before setting it.
This commit is contained in:
@@ -190,13 +190,12 @@ boost::asio::ip::tcp::socket sock{ioc};
|
||||
{
|
||||
stream<boost::asio::ip::tcp::socket> ws{ioc};
|
||||
//[ws_snippet_17
|
||||
auto cb =
|
||||
ws.control_callback(
|
||||
[](frame_type kind, string_view payload)
|
||||
{
|
||||
// Do something with the payload
|
||||
boost::ignore_unused(kind, payload);
|
||||
};
|
||||
ws.control_callback(cb);
|
||||
});
|
||||
//]
|
||||
|
||||
//[ws_snippet_18
|
||||
|
||||
Reference in New Issue
Block a user