Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:46:52

0001 #ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
0002 #define BOOST_MP11_FUNCTION_HPP_INCLUDED
0003 
0004 // Copyright 2015-2019 Peter Dimov.
0005 //
0006 // Distributed under the Boost Software License, Version 1.0.
0007 //
0008 // See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt
0010 
0011 #include <boost/mp11/integral.hpp>
0012 #include <boost/mp11/utility.hpp>
0013 #include <boost/mp11/detail/mp_list.hpp>
0014 #include <boost/mp11/detail/mp_count.hpp>
0015 #include <boost/mp11/detail/mp_plus.hpp>
0016 #include <boost/mp11/detail/mp_min_element.hpp>
0017 #include <boost/mp11/detail/mp_void.hpp>
0018 #include <boost/mp11/detail/config.hpp>
0019 #include <type_traits>
0020 
0021 namespace boost
0022 {
0023 namespace mp11
0024 {
0025 
0026 // mp_void<T...>
0027 //   in detail/mp_void.hpp
0028 
0029 // mp_and<T...>
0030 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1910 )
0031 
0032 namespace detail
0033 {
0034 
0035 template<class... T> struct mp_and_impl;
0036 
0037 } // namespace detail
0038 
0039 template<class... T> using mp_and = mp_to_bool< typename detail::mp_and_impl<T...>::type >;
0040 
0041 namespace detail
0042 {
0043 
0044 template<> struct mp_and_impl<>
0045 {
0046     using type = mp_true;
0047 };
0048 
0049 template<class T> struct mp_and_impl<T>
0050 {
0051     using type = T;
0052 };
0053 
0054 template<class T1, class... T> struct mp_and_impl<T1, T...>
0055 {
0056     using type = mp_eval_if< mp_not<T1>, T1, mp_and, T... >;
0057 };
0058 
0059 } // namespace detail
0060 
0061 #else
0062 
0063 namespace detail
0064 {
0065 
0066 template<class L, class E = void> struct mp_and_impl
0067 {
0068     using type = mp_false;
0069 };
0070 
0071 template<class... T> struct mp_and_impl< mp_list<T...>, mp_void<mp_if<T, void>...> >
0072 {
0073     using type = mp_true;
0074 };
0075 
0076 } // namespace detail
0077 
0078 template<class... T> using mp_and = typename detail::mp_and_impl<mp_list<T...>>::type;
0079 
0080 #endif
0081 
0082 // mp_all<T...>
0083 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86355
0084 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, != 0 )
0085 
0086 template<class... T> using mp_all = mp_bool< mp_count_if< mp_list<T...>, mp_not >::value == 0 >;
0087 
0088 #else
0089 
0090 template<class... T> using mp_all = mp_bool< mp_count< mp_list<mp_to_bool<T>...>, mp_false >::value == 0 >;
0091 
0092 #endif
0093 
0094 // mp_or<T...>
0095 namespace detail
0096 {
0097 
0098 template<class... T> struct mp_or_impl;
0099 
0100 } // namespace detail
0101 
0102 template<class... T> using mp_or = mp_to_bool< typename detail::mp_or_impl<T...>::type >;
0103 
0104 namespace detail
0105 {
0106 
0107 template<> struct mp_or_impl<>
0108 {
0109     using type = mp_false;
0110 };
0111 
0112 template<class T> struct mp_or_impl<T>
0113 {
0114     using type = T;
0115 };
0116 
0117 template<class T1, class... T> struct mp_or_impl<T1, T...>
0118 {
0119     using type = mp_eval_if< T1, T1, mp_or, T... >;
0120 };
0121 
0122 } // namespace detail
0123 
0124 // mp_any<T...>
0125 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86356
0126 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, != 0 )
0127 
0128 template<class... T> using mp_any = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value != 0 >;
0129 
0130 #else
0131 
0132 template<class... T> using mp_any = mp_bool< mp_count< mp_list<mp_to_bool<T>...>, mp_true >::value != 0 >;
0133 
0134 #endif
0135 
0136 // mp_same<T...>
0137 namespace detail
0138 {
0139 
0140 template<class... T> struct mp_same_impl;
0141 
0142 template<> struct mp_same_impl<>
0143 {
0144     using type = mp_true;
0145 };
0146 
0147 template<class T1, class... T> struct mp_same_impl<T1, T...>
0148 {
0149     using type = mp_bool< mp_count<mp_list<T...>, T1>::value == sizeof...(T) >;
0150 };
0151 
0152 } // namespace detail
0153 
0154 template<class... T> using mp_same = typename detail::mp_same_impl<T...>::type;
0155 
0156 // mp_similar<T...>
0157 namespace detail
0158 {
0159 
0160 template<class... T> struct mp_similar_impl;
0161 
0162 template<> struct mp_similar_impl<>
0163 {
0164     using type = mp_true;
0165 };
0166 
0167 template<class T> struct mp_similar_impl<T>
0168 {
0169     using type = mp_true;
0170 };
0171 
0172 template<class T> struct mp_similar_impl<T, T>
0173 {
0174     using type = mp_true;
0175 };
0176 
0177 template<class T1, class T2> struct mp_similar_impl<T1, T2>
0178 {
0179     using type = mp_false;
0180 };
0181 
0182 template<template<class...> class L, class... T1, class... T2> struct mp_similar_impl<L<T1...>, L<T2...>>
0183 {
0184     using type = mp_true;
0185 };
0186 
0187 template<template<class...> class L, class... T> struct mp_similar_impl<L<T...>, L<T...>>
0188 {
0189     using type = mp_true;
0190 };
0191 
0192 template<class T1, class T2, class T3, class... T> struct mp_similar_impl<T1, T2, T3, T...>
0193 {
0194     using type = mp_all< typename mp_similar_impl<T1, T2>::type, typename mp_similar_impl<T1, T3>::type, typename mp_similar_impl<T1, T>::type... >;
0195 };
0196 
0197 } // namespace detail
0198 
0199 template<class... T> using mp_similar = typename detail::mp_similar_impl<T...>::type;
0200 
0201 #if BOOST_MP11_GCC
0202 # pragma GCC diagnostic push
0203 # pragma GCC diagnostic ignored "-Wsign-compare"
0204 #endif
0205 
0206 // mp_less<T1, T2>
0207 template<class T1, class T2> using mp_less = mp_bool<(T1::value < 0 && T2::value >= 0) || ((T1::value < T2::value) && !(T1::value >= 0 && T2::value < 0))>;
0208 
0209 #if BOOST_MP11_GCC
0210 # pragma GCC diagnostic pop
0211 #endif
0212 
0213 // mp_min<T...>
0214 template<class T1, class... T> using mp_min = mp_min_element<mp_list<T1, T...>, mp_less>;
0215 
0216 // mp_max<T...>
0217 template<class T1, class... T> using mp_max = mp_max_element<mp_list<T1, T...>, mp_less>;
0218 
0219 } // namespace mp11
0220 } // namespace boost
0221 
0222 #endif // #ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED