Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:56

0001 #ifndef BOOST_MP11_SET_HPP_INCLUDED
0002 #define BOOST_MP11_SET_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/utility.hpp>
0012 #include <boost/mp11/function.hpp>
0013 #include <boost/mp11/detail/mp_list.hpp>
0014 #include <boost/mp11/detail/mp_append.hpp>
0015 #include <boost/mp11/detail/mp_copy_if.hpp>
0016 #include <boost/mp11/detail/mp_remove_if.hpp>
0017 #include <boost/mp11/detail/mp_is_list.hpp>
0018 #include <type_traits>
0019 
0020 namespace boost
0021 {
0022 namespace mp11
0023 {
0024 
0025 // mp_set_contains<S, V>
0026 namespace detail
0027 {
0028 
0029 template<class S, class V> struct mp_set_contains_impl
0030 {
0031 };
0032 
0033 template<template<class...> class L, class... T, class V> struct mp_set_contains_impl<L<T...>, V>
0034 {
0035     using type = mp_to_bool<std::is_base_of<mp_identity<V>, mp_inherit<mp_identity<T>...> > >;
0036 };
0037 
0038 } // namespace detail
0039 
0040 template<class S, class V> using mp_set_contains = typename detail::mp_set_contains_impl<S, V>::type;
0041 
0042 // mp_set_push_back<S, T...>
0043 namespace detail
0044 {
0045 
0046 template<class S, class... T> struct mp_set_push_back_impl
0047 {
0048 };
0049 
0050 template<template<class...> class L, class... U> struct mp_set_push_back_impl<L<U...>>
0051 {
0052     using type = L<U...>;
0053 };
0054 
0055 template<template<class...> class L, class... U, class T1, class... T> struct mp_set_push_back_impl<L<U...>, T1, T...>
0056 {
0057     using S = mp_if<mp_set_contains<L<U...>, T1>, L<U...>, L<U..., T1>>;
0058     using type = typename mp_set_push_back_impl<S, T...>::type;
0059 };
0060 
0061 } // namespace detail
0062 
0063 template<class S, class... T> using mp_set_push_back = typename detail::mp_set_push_back_impl<S, T...>::type;
0064 
0065 // mp_set_push_front<S, T...>
0066 namespace detail
0067 {
0068 
0069 template<class S, class... T> struct mp_set_push_front_impl
0070 {
0071 };
0072 
0073 template<template<class...> class L, class... U> struct mp_set_push_front_impl<L<U...>>
0074 {
0075     using type = L<U...>;
0076 };
0077 
0078 template<template<class...> class L, class... U, class T1> struct mp_set_push_front_impl<L<U...>, T1>
0079 {
0080     using type = mp_if<mp_set_contains<L<U...>, T1>, L<U...>, L<T1, U...>>;
0081 };
0082 
0083 template<template<class...> class L, class... U, class T1, class... T> struct mp_set_push_front_impl<L<U...>, T1, T...>
0084 {
0085     using S = typename mp_set_push_front_impl<L<U...>, T...>::type;
0086     using type = typename mp_set_push_front_impl<S, T1>::type;
0087 };
0088 
0089 } // namespace detail
0090 
0091 template<class S, class... T> using mp_set_push_front = typename detail::mp_set_push_front_impl<S, T...>::type;
0092 
0093 // mp_is_set<S>
0094 namespace detail
0095 {
0096 
0097 template<class S> struct mp_is_set_impl
0098 {
0099     using type = mp_false;
0100 };
0101 
0102 template<template<class...> class L, class... T> struct mp_is_set_impl<L<T...>>
0103 {
0104     using type = mp_to_bool<std::is_same<mp_list<T...>, mp_set_push_back<mp_list<>, T...> > >;
0105 };
0106 
0107 } // namespace detail
0108 
0109 template<class S> using mp_is_set = typename detail::mp_is_set_impl<S>::type;
0110 
0111 // mp_set_union<L...>
0112 namespace detail
0113 {
0114 
0115 template<class... L> struct mp_set_union_impl
0116 {
0117 };
0118 
0119 template<> struct mp_set_union_impl<>
0120 {
0121     using type = mp_list<>;
0122 };
0123 
0124 template<template<class...> class L, class... T> struct mp_set_union_impl<L<T...>>
0125 {
0126     using type = L<T...>;
0127 };
0128 
0129 template<template<class...> class L1, class... T1, template<class...> class L2, class... T2> struct mp_set_union_impl<L1<T1...>, L2<T2...>>
0130 {
0131     using type = mp_set_push_back<L1<T1...>, T2...>;
0132 };
0133 
0134 template<class L1, class... L> using mp_set_union_ = typename mp_set_union_impl<L1, mp_append<mp_list<>, L...>>::type;
0135 
0136 template<class L1, class L2, class L3, class... L> struct mp_set_union_impl<L1, L2, L3, L...>: mp_defer<mp_set_union_, L1, L2, L3, L...>
0137 {
0138 };
0139 
0140 } // namespace detail
0141 
0142 template<class... L> using mp_set_union = typename detail::mp_set_union_impl<L...>::type;
0143 
0144 // mp_set_intersection<S...>
0145 namespace detail
0146 {
0147 
0148 template<class... S> struct in_all_sets
0149 {
0150     template<class T> using fn = mp_all< mp_set_contains<S, T>... >;
0151 };
0152 
0153 template<class L, class... S> using mp_set_intersection_ = mp_if< mp_all<mp_is_list<S>...>, mp_copy_if_q<L, detail::in_all_sets<S...>> >;
0154 
0155 template<class... S> struct mp_set_intersection_impl
0156 {
0157 };
0158 
0159 template<> struct mp_set_intersection_impl<>
0160 {
0161     using type = mp_list<>;
0162 };
0163 
0164 template<class L, class... S> struct mp_set_intersection_impl<L, S...>: mp_defer<mp_set_intersection_, L, S...>
0165 {
0166 };
0167 
0168 } // namespace detail
0169 
0170 template<class... S> using mp_set_intersection = typename detail::mp_set_intersection_impl<S...>::type;
0171 
0172 // mp_set_difference<L, S...>
0173 namespace detail
0174 {
0175 
0176 template<class... S> struct in_any_set
0177 {
0178     template<class T> using fn = mp_any< mp_set_contains<S, T>... >;
0179 };
0180 
0181 } // namespace detail
0182 
0183 template<class L, class... S> using mp_set_difference = mp_if< mp_all<mp_is_list<S>...>, mp_remove_if_q<L, detail::in_any_set<S...>> >;
0184 
0185 } // namespace mp11
0186 } // namespace boost
0187 
0188 #endif // #ifndef BOOST_MP11_SET_HPP_INCLUDED