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