1[/ 2 / Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 3 / 4 / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 /] 7 8[section:MoveAcceptHandler Move accept handler requirements] 9 10A move accept handler must meet the requirements for a [link 11boost_asio.reference.Handler handler]. A value `h` of a move accept handler class 12should work correctly in the expression `h(ec, s)`, where `ec` is an lvalue of 13type `const error_code` and `s` is an lvalue of the nested type 14`Protocol::socket` for the type `Protocol` of the socket class template. 15 16[heading Examples] 17 18A free function as a move accept handler: 19 20 void accept_handler( 21 const boost::system::error_code& ec, boost::asio::ip::tcp::socket s) 22 { 23 ... 24 } 25 26A move accept handler function object: 27 28 struct accept_handler 29 { 30 ... 31 void operator()( 32 const boost::system::error_code& ec, boost::asio::ip::tcp::socket s) 33 { 34 ... 35 } 36 ... 37 }; 38 39A lambda as a move accept handler: 40 41 acceptor.async_accept(..., 42 [](const boost::system::error_code& ec, boost::asio::ip::tcp::socket s) 43 { 44 ... 45 }); 46 47A non-static class member function adapted to a move accept handler using 48`std::bind()`: 49 50 void my_class::accept_handler( 51 const boost::system::error_code& ec, boost::asio::ip::tcp::socket socket) 52 { 53 ... 54 } 55 ... 56 boost::asio::async_accept(..., 57 std::bind(&my_class::accept_handler, 58 this, std::placeholders::_1, 59 std::placeholders::_2)); 60 61[endsect] 62