#ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED #define BOOST_MP11_FUNCTION_HPP_INCLUDED // Copyright 2015-2019 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 #include #include #include namespace boost { namespace mp11 { // mp_void // in detail/mp_void.hpp // mp_and #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1910 ) namespace detail { template struct mp_and_impl; } // namespace detail template using mp_and = mp_to_bool< typename detail::mp_and_impl::type >; namespace detail { template<> struct mp_and_impl<> { using type = mp_true; }; template struct mp_and_impl { using type = T; }; template struct mp_and_impl { using type = mp_eval_if< mp_not, T1, mp_and, T... >; }; } // namespace detail #else namespace detail { template struct mp_and_impl { using type = mp_false; }; template struct mp_and_impl< mp_list, mp_void...> > { using type = mp_true; }; } // namespace detail template using mp_and = typename detail::mp_and_impl>::type; #endif // mp_all // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86355 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, != 0 ) template using mp_all = mp_bool< mp_count_if< mp_list, mp_not >::value == 0 >; #elif defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) template using mp_all = mp_bool<(static_cast(T::value) && ...)>; #else template using mp_all = mp_and...>; #endif // mp_or namespace detail { template struct mp_or_impl; } // namespace detail template using mp_or = mp_to_bool< typename detail::mp_or_impl::type >; namespace detail { template<> struct mp_or_impl<> { using type = mp_false; }; template struct mp_or_impl { using type = T; }; template struct mp_or_impl { using type = mp_eval_if< T1, T1, mp_or, T... >; }; } // namespace detail // mp_any // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86356 #if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, != 0 ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template using mp_any = mp_bool<(static_cast(T::value) || ...)>; #else template using mp_any = mp_bool< mp_count_if< mp_list, mp_to_bool >::value != 0 >; #endif // mp_same namespace detail { template struct mp_same_impl; template<> struct mp_same_impl<> { using type = mp_true; }; template struct mp_same_impl { using type = mp_all...>; }; } // namespace detail template using mp_same = typename detail::mp_same_impl::type; // mp_similar namespace detail { template struct mp_similar_impl; template<> struct mp_similar_impl<> { using type = mp_true; }; template struct mp_similar_impl { using type = mp_true; }; template struct mp_similar_impl { using type = mp_true; }; template struct mp_similar_impl { using type = mp_false; }; template class L, class... T1, class... T2> struct mp_similar_impl, L> { using type = mp_true; }; template struct mp_similar_impl { using type = mp_all< typename mp_similar_impl::type, typename mp_similar_impl::type, typename mp_similar_impl::type... >; }; } // namespace detail template using mp_similar = typename detail::mp_similar_impl::type; #if BOOST_MP11_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" #endif // mp_less template using mp_less = mp_bool<(T1::value < 0 && T2::value >= 0) || ((T1::value < T2::value) && !(T1::value >= 0 && T2::value < 0))>; #if BOOST_MP11_GCC # pragma GCC diagnostic pop #endif // mp_min template using mp_min = mp_min_element, mp_less>; // mp_max template using mp_max = mp_max_element, mp_less>; } // namespace mp11 } // namespace boost #endif // #ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED