X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fmp11%2Falgorithm.hpp;h=b8719d68768f1e729aa46cf5bebc0a4c0debf992;hb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;hp=23758f7076102bf1a962d8a772e3d8a92d165c7b;hpb=a0324939f9d0e1905d5df8f57442f09dc70af83d;p=ceph.git diff --git a/ceph/src/boost/boost/mp11/algorithm.hpp b/ceph/src/boost/boost/mp11/algorithm.hpp index 23758f707..b8719d687 100644 --- a/ceph/src/boost/boost/mp11/algorithm.hpp +++ b/ceph/src/boost/boost/mp11/algorithm.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED #define BOOST_MP11_ALGORITHM_HPP_INCLUDED -// Copyright 2015-2017 Peter Dimov. +// Copyright 2015-2019 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // @@ -19,10 +19,10 @@ #include #include #include +#include +#include #include #include -#include -#include #include #include @@ -41,7 +41,7 @@ template class F, class... L> struct mp_transform_impl template class F, template class L, class... T> struct mp_transform_impl> { -#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct f { using type = F; }; @@ -56,7 +56,7 @@ template class F, template class L, class... T> str template class F, template class L1, class... T1, template class L2, class... T2> struct mp_transform_impl, L2> { -#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct f { using type = F; }; @@ -71,7 +71,7 @@ template class F, template class L1, class... T1, t template class F, template class L1, class... T1, template class L2, class... T2, template class L3, class... T3> struct mp_transform_impl, L2, L3> { -#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct f { using type = F; }; @@ -84,7 +84,7 @@ template class F, template class L1, class... T1, t #endif }; -#if BOOST_WORKAROUND( BOOST_MSVC, == 1900 ) || BOOST_WORKAROUND( BOOST_GCC, < 40800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, == 1900 ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) template using mp_same_size_1 = mp_same...>; template struct mp_same_size_2: mp_defer {}; @@ -95,18 +95,35 @@ struct list_size_mismatch { }; +#if BOOST_MP11_WORKAROUND( BOOST_MP11_CUDA, >= 9000000 && BOOST_MP11_CUDA < 10000000 ) + +template class F, class... L> struct mp_transform_cuda_workaround +{ + using type = mp_if...>, detail::mp_transform_impl, detail::list_size_mismatch>; +}; + +#endif + } // namespace detail -#if BOOST_WORKAROUND( BOOST_MSVC, == 1900 ) || BOOST_WORKAROUND( BOOST_GCC, < 40800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, == 1900 ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) template class F, class... L> using mp_transform = typename mp_if::type, detail::mp_transform_impl, detail::list_size_mismatch>::type; #else +#if BOOST_MP11_WORKAROUND( BOOST_MP11_CUDA, >= 9000000 && BOOST_MP11_CUDA < 10000000 ) + +template class F, class... L> using mp_transform = typename detail::mp_transform_cuda_workaround< F, L...>::type::type; + +#else + template class F, class... L> using mp_transform = typename mp_if...>, detail::mp_transform_impl, detail::list_size_mismatch>::type; #endif +#endif + template using mp_transform_q = mp_transform; namespace detail @@ -138,14 +155,14 @@ template class P, template class F, class... L> str using Qp = mp_quote

; using Qf = mp_quote; -#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) - template struct _f_ { using type = mp_eval_if_q>, mp_first>, Qf, U...>; }; + template struct _f_ { using type = mp_eval_if_q>, mp_first>, Qf, U...>; }; template using _f = typename _f_::type; #else - template using _f = mp_eval_if_q>, mp_first>, Qf, U...>; + template using _f = mp_eval_if_q>, mp_first>, Qf, U...>; #endif @@ -157,6 +174,27 @@ template class P, template class F, class... L> str template class P, template class F, class... L> using mp_transform_if = typename detail::mp_transform_if_impl::type; template using mp_transform_if_q = typename detail::mp_transform_if_impl::type; +// mp_filter +namespace detail +{ + +template class P, class L1, class... L> struct mp_filter_impl +{ + using Qp = mp_quote

; + + template using _f = mp_if< mp_invoke_q, mp_list, mp_list<> >; + + using _t1 = mp_transform<_f, L1, L...>; + using _t2 = mp_apply; + + using type = mp_assign; +}; + +} // namespace detail + +template class P, class... L> using mp_filter = typename detail::mp_filter_impl::type; +template using mp_filter_q = typename detail::mp_filter_impl::type; + // mp_fill namespace detail { @@ -165,7 +203,7 @@ template struct mp_fill_impl; template class L, class... T, class V> struct mp_fill_impl, V> { -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1900 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1900 ) template struct _f { using type = V; }; using type = L::type...>; @@ -297,57 +335,119 @@ template class L, class... T, std::size_t I> struct mp_at_c_i template struct mp_at_c_impl { - using _map = mp_transform>, L>; - using type = mp_second>>; + using _map = mp_transform >, L>; + using type = mp_second > >; +}; + +#endif + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_CUDA, >= 9000000 && BOOST_MP11_CUDA < 10000000 ) + +template struct mp_at_c_cuda_workaround +{ + using type = mp_if_c<(I < mp_size::value), detail::mp_at_c_impl, void>; }; #endif } // namespace detail +#if BOOST_MP11_WORKAROUND( BOOST_MP11_CUDA, >= 9000000 && BOOST_MP11_CUDA < 10000000 ) + +template using mp_at_c = typename detail::mp_at_c_cuda_workaround< L, I >::type::type; + +#else + template using mp_at_c = typename mp_if_c<(I < mp_size::value), detail::mp_at_c_impl, void>::type; + +#endif + template using mp_at = mp_at_c; // mp_take(_c) namespace detail { -template struct mp_take_c_impl; +template struct mp_take_c_impl +{ +}; -template class L, class... T> struct mp_take_c_impl, 0> +template class L, class... T> +struct mp_take_c_impl<0, L> { using type = L<>; }; -template class L, class T1, class... T> struct mp_take_c_impl, 1> +template class L, class T1, class... T> +struct mp_take_c_impl<1, L> { using type = L; }; -template class L, class T1, class T2, class... T> struct mp_take_c_impl, 2> +template class L, class T1, class T2, class... T> +struct mp_take_c_impl<2, L> { using type = L; }; -template class L, class T1, class T2, class T3, class... T> struct mp_take_c_impl, 3> +template class L, class T1, class T2, class T3, class... T> +struct mp_take_c_impl<3, L> { using type = L; }; -template class L, class T1, class T2, class T3, class T4, class... T> struct mp_take_c_impl, 4> +template class L, class T1, class T2, class T3, class T4, class... T> +struct mp_take_c_impl<4, L> { using type = L; }; -template class L, class T1, class T2, class T3, class T4, class T5, class... T, std::size_t N> struct mp_take_c_impl, N, typename std::enable_if= 5>::type> +template class L, class T1, class T2, class T3, class T4, class T5, class... T> +struct mp_take_c_impl<5, L> { - using type = mp_append, typename mp_take_c_impl, N-5>::type>; + using type = L; +}; + +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class... T> +struct mp_take_c_impl<6, L> +{ + using type = L; +}; + +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class... T> +struct mp_take_c_impl<7, L> +{ + using type = L; +}; + +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class... T> +struct mp_take_c_impl<8, L> +{ + using type = L; +}; + +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class... T> +struct mp_take_c_impl<9, L> +{ + using type = L; +}; + +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, std::size_t N> +struct mp_take_c_impl, typename std::enable_if= 10>::type> +{ + using type = mp_append, typename mp_take_c_impl>::type>; }; } // namespace detail -template using mp_take_c = typename detail::mp_take_c_impl::type; -template using mp_take = typename detail::mp_take_c_impl::type; +template using mp_take_c = typename detail::mp_take_c_impl::type; +template using mp_take = typename detail::mp_take_c_impl::type; + +// mp_back +template using mp_back = mp_at_c::value - 1>; + +// mp_pop_back +template using mp_pop_back = mp_take_c::value - 1>; // mp_replace namespace detail @@ -357,7 +457,7 @@ template struct mp_replace_impl; template class L, class... T, class V, class W> struct mp_replace_impl, V, W> { -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) template struct _f { using type = mp_if, W, A>; }; using type = L::type...>; #else @@ -378,7 +478,7 @@ template class P, class W> struct mp_replace_if_impl template class L, class... T, template class P, class W> struct mp_replace_if_impl, P, W> { -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct _f { using type = mp_if, W, U>; }; using type = L::type...>; #else @@ -393,26 +493,7 @@ template class P, class W> using mp_replace_if = typ template using mp_replace_if_q = mp_replace_if; // mp_copy_if -namespace detail -{ - -template class P> struct mp_copy_if_impl; - -template class L, class... T, template class P> struct mp_copy_if_impl, P> -{ -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) - template struct _f { using type = mp_if, mp_list, mp_list<>>; }; - using type = mp_append, typename _f::type...>; -#else - template using _f = mp_if, mp_list, mp_list<>>; - using type = mp_append, _f...>; -#endif -}; - -} // namespace detail - -template class P> using mp_copy_if = typename detail::mp_copy_if_impl::type; -template using mp_copy_if_q = mp_copy_if; +// in detail/mp_copy_if.hpp // mp_remove namespace detail @@ -422,7 +503,7 @@ template struct mp_remove_impl; template class L, class... T, class V> struct mp_remove_impl, V> { -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct _f { using type = mp_if, mp_list<>, mp_list>; }; using type = mp_append, typename _f::type...>; #else @@ -436,26 +517,7 @@ template class L, class... T, class V> struct mp_remove_impl< template using mp_remove = typename detail::mp_remove_impl::type; // mp_remove_if -namespace detail -{ - -template class P> struct mp_remove_if_impl; - -template class L, class... T, template class P> struct mp_remove_if_impl, P> -{ -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) - template struct _f { using type = mp_if, mp_list<>, mp_list>; }; - using type = mp_append, typename _f::type...>; -#else - template using _f = mp_if, mp_list<>, mp_list>; - using type = mp_append, _f...>; -#endif -}; - -} // namespace detail - -template class P> using mp_remove_if = typename detail::mp_remove_if_impl::type; -template using mp_remove_if_q = mp_remove_if; +// in detail/mp_remove_if.hpp // mp_partition namespace detail @@ -479,7 +541,7 @@ namespace detail template class P> struct mp_sort_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) template class L, class... T, template class P> struct mp_sort_impl, P> { @@ -543,6 +605,26 @@ template class L, class T1, class... T, std::size_t I, templa using L2 = mp_second; +#if BOOST_MP11_WORKAROUND( BOOST_MP11_CUDA, >= 9000000 && BOOST_MP11_CUDA < 10000000 ) + + struct detail + { + struct mp_nth_element_impl_cuda_workaround + { + using type = mp_cond< + + mp_bool<(I < N1)>, mp_nth_element_impl, + mp_bool<(I == N1)>, mp_identity, + mp_true, mp_nth_element_impl + + >; + }; + }; + + using type = typename detail::mp_nth_element_impl_cuda_workaround::type::type; + +#else + using type = typename mp_cond< mp_bool<(I < N1)>, mp_nth_element_impl, @@ -550,6 +632,8 @@ template class L, class T1, class... T, std::size_t I, templa mp_true, mp_nth_element_impl >::type; + +#endif }; } // namespace detail @@ -564,7 +648,7 @@ namespace detail template struct mp_find_impl; -#if defined( BOOST_CLANG ) && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) +#if BOOST_MP11_CLANG && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) struct mp_index_holder { @@ -601,7 +685,7 @@ template class L, class V> struct mp_find_impl, V> using type = mp_size_t<0>; }; -#if !defined( BOOST_NO_CXX14_CONSTEXPR ) +#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR ) constexpr std::size_t cx_find_index( bool const * first, bool const * last ) { @@ -633,7 +717,7 @@ template class L, class... T, class V> struct mp_find_impl class L, class... T, class V> struct mp_find_impl, V> { @@ -673,7 +757,7 @@ namespace detail template class P> struct mp_find_if_impl; -#if defined( BOOST_CLANG ) && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) +#if BOOST_MP11_CLANG && defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) template class L, class... T, template class P> struct mp_find_if_impl, P> { @@ -696,7 +780,7 @@ template class L, class... T, template class P> str #else -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) template class L, class... T, template class P> struct mp_find_if_impl, P> { @@ -737,7 +821,7 @@ namespace detail template struct mp_reverse_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) template class L, class... T> struct mp_reverse_impl> { @@ -817,7 +901,7 @@ namespace detail template class F> struct mp_reverse_fold_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) template class L, class... T, class V, template class F> struct mp_reverse_fold_impl, V, F> { @@ -843,7 +927,7 @@ template class L, class T1, class... T, class V, template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, class V, template class F> struct mp_reverse_fold_impl, V, F> { using rest = typename mp_reverse_fold_impl, V, F>::type; - using type = F>>>>>>>>>; + using type = F > > > > > > > > >; }; } // namespace detail @@ -889,7 +973,7 @@ template struct mp_replace_at_impl template using _p = std::is_same>; template using _f = W; - using type = mp_transform_if<_p, _f, L, mp_iota>>; + using type = mp_transform_if<_p, _f, L, mp_iota > >; }; } // namespace detail @@ -901,24 +985,47 @@ template using mp_replace_at_c = typename detai namespace detail { -template BOOST_CONSTEXPR F mp_for_each_impl( mp_list, F && f ) +template BOOST_MP11_CONSTEXPR F mp_for_each_impl( mp_list, F && f ) { using A = int[sizeof...(T)]; return (void)A{ ((void)f(T()), 0)... }, std::forward(f); } -template BOOST_CONSTEXPR F mp_for_each_impl( mp_list<>, F && f ) +template BOOST_MP11_CONSTEXPR F mp_for_each_impl( mp_list<>, F && f ) { return std::forward(f); } } // namespace detail -template BOOST_CONSTEXPR F mp_for_each( F && f ) +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, >= 1900 ) + +// msvc has a limit of 1024 + +template BOOST_MP11_CONSTEXPR mp_if_c::value <= 1024, F> mp_for_each( F && f ) { return detail::mp_for_each_impl( mp_rename(), std::forward(f) ); } +template BOOST_MP11_CONSTEXPR mp_if_c::value >= 1025, F> mp_for_each( F && f ) +{ + using L2 = mp_rename; + + using L3 = mp_take_c; + using L4 = mp_drop_c; + + return mp_for_each( mp_for_each( std::forward(f) ) ); +} + +#else + +template BOOST_MP11_CONSTEXPR F mp_for_each( F && f ) +{ + return detail::mp_for_each_impl( mp_rename(), std::forward(f) ); +} + +#endif + // mp_insert template using mp_insert = mp_append, mp_push_front, T...>>; @@ -931,6 +1038,30 @@ template using mp_erase = mp_append, mp // mp_erase_c template using mp_erase_c = mp_append, mp_drop_c>; +// mp_starts_with +// contributed by Glen Joseph Fernandes (glenjofe@gmail.com) +namespace detail { + +template +struct mp_starts_with_impl { }; + +template class L1, class... T1, template class L2, + class... T2> +struct mp_starts_with_impl, L2 > { + template + static mp_false check(L); + + template + static mp_true check(mp_list); + + using type = decltype(check(mp_list())); +}; + +} // namespace detail + +template +using mp_starts_with = typename detail::mp_starts_with_impl::type; + // mp_min_element // mp_max_element // in detail/mp_min_element.hpp