annotate DEPENDENCIES/generic/include/boost/lockfree/detail/copy_payload.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // boost lockfree: copy_payload helper
Chris@16 2 //
Chris@16 3 // Copyright (C) 2011 Tim Blechmann
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 6 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 #ifndef BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
Chris@16 10 #define BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
Chris@16 11
Chris@16 12 #include <boost/mpl/if.hpp>
Chris@16 13 #include <boost/type_traits/is_convertible.hpp>
Chris@16 14
Chris@16 15 namespace boost {
Chris@16 16 namespace lockfree {
Chris@16 17 namespace detail {
Chris@16 18
Chris@16 19 struct copy_convertible
Chris@16 20 {
Chris@16 21 template <typename T, typename U>
Chris@16 22 static void copy(T & t, U & u)
Chris@16 23 {
Chris@16 24 u = t;
Chris@16 25 }
Chris@16 26 };
Chris@16 27
Chris@16 28 struct copy_constructible_and_copyable
Chris@16 29 {
Chris@16 30 template <typename T, typename U>
Chris@16 31 static void copy(T & t, U & u)
Chris@16 32 {
Chris@16 33 u = U(t);
Chris@16 34 }
Chris@16 35 };
Chris@16 36
Chris@16 37 template <typename T, typename U>
Chris@16 38 void copy_payload(T & t, U & u)
Chris@16 39 {
Chris@16 40 typedef typename boost::mpl::if_<typename boost::is_convertible<T, U>::type,
Chris@16 41 copy_convertible,
Chris@16 42 copy_constructible_and_copyable
Chris@16 43 >::type copy_type;
Chris@16 44 copy_type::copy(t, u);
Chris@16 45 }
Chris@16 46
Chris@16 47 template <typename T>
Chris@16 48 struct consume_via_copy
Chris@16 49 {
Chris@16 50 consume_via_copy(T & out):
Chris@101 51 out_(out)
Chris@16 52 {}
Chris@16 53
Chris@16 54 template <typename U>
Chris@16 55 void operator()(U & element)
Chris@16 56 {
Chris@101 57 copy_payload(element, out_);
Chris@16 58 }
Chris@16 59
Chris@101 60 T & out_;
Chris@101 61 };
Chris@101 62
Chris@101 63 struct consume_noop
Chris@101 64 {
Chris@101 65 template <typename U>
Chris@101 66 void operator()(const U &)
Chris@101 67 {
Chris@101 68 }
Chris@16 69 };
Chris@16 70
Chris@16 71
Chris@16 72 }}}
Chris@16 73
Chris@16 74 #endif /* BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED */