]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/base_from_completion_cond.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / base_from_completion_cond.hpp
1 //
2 // detail/base_from_completion_cond.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #ifndef BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
12 #define BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/completion_condition.hpp>
20
21 #include <boost/asio/detail/push_options.hpp>
22
23 namespace boost {
24 namespace asio {
25 namespace detail {
26
27 template <typename CompletionCondition>
28 class base_from_completion_cond
29 {
30 protected:
31 explicit base_from_completion_cond(CompletionCondition& completion_condition)
32 : completion_condition_(
33 BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition))
34 {
35 }
36
37 std::size_t check_for_completion(
38 const boost::system::error_code& ec,
39 std::size_t total_transferred)
40 {
41 return detail::adapt_completion_condition_result(
42 completion_condition_(ec, total_transferred));
43 }
44
45 private:
46 CompletionCondition completion_condition_;
47 };
48
49 template <>
50 class base_from_completion_cond<transfer_all_t>
51 {
52 protected:
53 explicit base_from_completion_cond(transfer_all_t)
54 {
55 }
56
57 static std::size_t check_for_completion(
58 const boost::system::error_code& ec,
59 std::size_t total_transferred)
60 {
61 return transfer_all_t()(ec, total_transferred);
62 }
63 };
64
65 } // namespace detail
66 } // namespace asio
67 } // namespace boost
68
69 #include <boost/asio/detail/pop_options.hpp>
70
71 #endif // BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP