]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/lockfree/detail/copy_payload.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / lockfree / detail / copy_payload.hpp
1 // boost lockfree: copy_payload helper
2 //
3 // Copyright (C) 2011, 2016 Tim Blechmann
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #ifndef BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
10 #define BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
11
12 #include <boost/mpl/if.hpp>
13 #include <boost/type_traits/is_convertible.hpp>
14
15 #if defined(_MSC_VER)
16 #pragma warning(push)
17 #pragma warning(disable: 4512) // assignment operator could not be generated
18 #endif
19
20 namespace boost {
21 namespace lockfree {
22 namespace detail {
23
24 struct copy_convertible
25 {
26 template <typename T, typename U>
27 static void copy(T & t, U & u)
28 {
29 u = t;
30 }
31 };
32
33 struct copy_constructible_and_copyable
34 {
35 template <typename T, typename U>
36 static void copy(T & t, U & u)
37 {
38 u = U(t);
39 }
40 };
41
42 template <typename T, typename U>
43 void copy_payload(T & t, U & u)
44 {
45 typedef typename boost::mpl::if_<typename boost::is_convertible<T, U>::type,
46 copy_convertible,
47 copy_constructible_and_copyable
48 >::type copy_type;
49 copy_type::copy(t, u);
50 }
51
52 template <typename T>
53 struct consume_via_copy
54 {
55 consume_via_copy(T & out):
56 out_(out)
57 {}
58
59 template <typename U>
60 void operator()(U & element)
61 {
62 copy_payload(element, out_);
63 }
64
65 T & out_;
66 };
67
68 struct consume_noop
69 {
70 template <typename U>
71 void operator()(const U &)
72 {
73 }
74 };
75
76
77 }}}
78
79 #if defined(_MSC_VER)
80 #pragma warning(pop)
81 #endif
82
83 #endif /* BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED */