1 // boost lockfree: copy_payload helper
3 // Copyright (C) 2011, 2016 Tim Blechmann
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)
9 #ifndef BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
10 #define BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
12 #include <boost/mpl/if.hpp>
13 #include <boost/type_traits/is_convertible.hpp>
17 #pragma warning(disable: 4512) // assignment operator could not be generated
24 struct copy_convertible
26 template <typename T, typename U>
27 static void copy(T & t, U & u)
33 struct copy_constructible_and_copyable
35 template <typename T, typename U>
36 static void copy(T & t, U & u)
42 template <typename T, typename U>
43 void copy_payload(T & t, U & u)
45 typedef typename boost::mpl::if_<typename boost::is_convertible<T, U>::type,
47 copy_constructible_and_copyable
49 copy_type::copy(t, u);
53 struct consume_via_copy
55 consume_via_copy(T & out):
60 void operator()(U & element)
62 copy_payload(element, out_);
71 void operator()(const U &)
83 #endif /* BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED */