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:
Vinnie Falco
2017-11-27 15:05:58 -08:00
parent ab91844039
commit 8181851719
4 changed files with 29 additions and 33 deletions
+2 -3
View File
@@ -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