#ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED #define BOOST_MP11_ALGORITHM_HPP_INCLUDED // Copyright 2015 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include #include #include #include #include #include namespace boost { // mp_assign namespace detail { template struct mp_assign_impl; template class L1, class... T, template class L2, class... U> struct mp_assign_impl, L2> { using type = L1; }; } // namespace detail template using mp_assign = typename detail::mp_assign_impl::type; // mp_clear template using mp_clear = mp_assign>; // mp_transform namespace detail { template class F, class... L> struct mp_transform_impl; template class F, class... L> using mp_transform = typename mp_transform_impl::type; template class F, template class L, class... T> struct mp_transform_impl> { using type = L...>; }; template class F, template class L1, class... T1, template class L2, class... T2> struct mp_transform_impl, L2> { static_assert( sizeof...(T1) == sizeof...(T2), "The arguments of mp_transform should be of the same size" ); using type = L1...>; }; template class F, template class L1, class... T1, template class L2, class... T2, template class L3, class... T3> struct mp_transform_impl, L2, L3> { static_assert( sizeof...(T1) == sizeof...(T2) && sizeof...(T1) == sizeof...(T3), "The arguments of mp_transform should be of the same size" ); using type = L1...>; }; } // namespace detail template class F, class... L> using mp_transform = typename detail::mp_transform_impl::type; // mp_fill namespace detail { 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, <= 1800 ) template struct _f { using type = V; }; using type = L::type...>; #else template using _f = V; using type = L<_f...>; #endif }; } // namespace detail template using mp_fill = typename detail::mp_fill_impl::type; // mp_count namespace detail { template struct mp_count_impl; template class L, class... T, class V> struct mp_count_impl, V> { using type = mp_plus...>; }; } // namespace detail template using mp_count = typename detail::mp_count_impl::type; // mp_count_if namespace detail { template class P> struct mp_count_if_impl; template class L, class... T, template class P> struct mp_count_if_impl, P> { #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) template struct _f { using type = mp_to_bool>; }; using type = mp_plus::type...>; #else using type = mp_plus>...>; #endif }; } // namespace detail template class P> using mp_count_if = typename detail::mp_count_if_impl::type; // mp_contains template using mp_contains = mp_to_bool>; // mp_repeat(_c) namespace detail { template struct mp_repeat_c_impl { using _l1 = typename mp_repeat_c_impl::type; using _l2 = typename mp_repeat_c_impl::type; using type = mp_append<_l1, _l1, _l2>; }; template struct mp_repeat_c_impl { using type = mp_clear; }; template struct mp_repeat_c_impl { using type = L; }; template struct mp_repeat_impl { static_assert( N::value >= 0, "mp_repeat: N must not be negative" ); using type = typename mp_repeat_c_impl::type; }; } // namespace detail template using mp_repeat_c = typename detail::mp_repeat_c_impl::type; template using mp_repeat = typename detail::mp_repeat_impl::type; // mp_drop // mp_take // mp_find // mp_find_if // mp_find_index // mp_find_index_if // mp_reverse // mp_copy_if // mp_remove_if // mp_product? // mp_fold // mp_reverse_fold // mp_replace? // mp_replace_if? // mp_partition // mp_sort } // namespace boost #endif // #ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED