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:LegacyCompletionHandler Legacy completion handler requirements] 9 10A legacy completion handler must meet the requirements for a [link 11boost_asio.reference.Handler handler]. A legacy completion handler must meet the 12requirements of `CopyConstructible` types (C++Std [copyconstructible]). A value 13`h` of a completion handler class should work correctly in the expression 14`h()`. 15 16[heading Examples] 17 18A free function as a completion handler: 19 20 void completion_handler() 21 { 22 ... 23 } 24 25A completion handler function object: 26 27 struct completion_handler 28 { 29 ... 30 void operator()() 31 { 32 ... 33 } 34 ... 35 }; 36 37A lambda as a completion handler: 38 39 my_io_service.post( 40 []() 41 { 42 ... 43 }); 44 45A non-static class member function adapted to a completion handler using 46`std::bind()`: 47 48 void my_class::completion_handler() 49 { 50 ... 51 } 52 ... 53 my_io_service.post(std::bind(&my_class::completion_handler, this)); 54 55A non-static class member function adapted to a completion handler using 56`boost::bind()`: 57 58 void my_class::completion_handler() 59 { 60 ... 61 } 62 ... 63 my_io_service.post(boost::bind(&my_class::completion_handler, this)); 64 65[endsect] 66