Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:56:15

0001 #ifndef BOOST_MP11_LIST_HPP_INCLUDED
0002 #define BOOST_MP11_LIST_HPP_INCLUDED
0003 
0004 //  Copyright 2015-2023 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/detail/mp_list.hpp>
0013 #include <boost/mp11/detail/mp_list_v.hpp>
0014 #include <boost/mp11/detail/mp_is_list.hpp>
0015 #include <boost/mp11/detail/mp_is_value_list.hpp>
0016 #include <boost/mp11/detail/mp_front.hpp>
0017 #include <boost/mp11/detail/mp_rename.hpp>
0018 #include <boost/mp11/detail/mp_append.hpp>
0019 #include <boost/mp11/detail/config.hpp>
0020 #include <type_traits>
0021 
0022 #if defined(_MSC_VER) || defined(__GNUC__)
0023 # pragma push_macro( "I" )
0024 # undef I
0025 #endif
0026 
0027 namespace boost
0028 {
0029 namespace mp11
0030 {
0031 
0032 // mp_list<T...>
0033 //   in detail/mp_list.hpp
0034 
0035 // mp_list_c<T, I...>
0036 template<class T, T... I> using mp_list_c = mp_list<std::integral_constant<T, I>...>;
0037 
0038 // mp_list_v<A...>
0039 //   in detail/mp_list_v.hpp
0040 
0041 // mp_is_list<L>
0042 //   in detail/mp_is_list.hpp
0043 
0044 // mp_is_value_list<L>
0045 //   in detail/mp_is_value_list.hpp
0046 
0047 // mp_size<L>
0048 namespace detail
0049 {
0050 
0051 template<class L> struct mp_size_impl
0052 {
0053 // An error "no type named 'type'" here means that the argument to mp_size is not a list
0054 };
0055 
0056 template<template<class...> class L, class... T> struct mp_size_impl<L<T...>>
0057 {
0058     using type = mp_size_t<sizeof...(T)>;
0059 };
0060 
0061 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0062 
0063 template<template<auto...> class L, auto... A> struct mp_size_impl<L<A...>>
0064 {
0065     using type = mp_size_t<sizeof...(A)>;
0066 };
0067 
0068 #endif
0069 
0070 } // namespace detail
0071 
0072 template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
0073 
0074 // mp_empty<L>
0075 template<class L> using mp_empty = mp_bool< mp_size<L>::value == 0 >;
0076 
0077 // mp_assign<L1, L2>
0078 namespace detail
0079 {
0080 
0081 template<class L1, class L2> struct mp_assign_impl
0082 {
0083 // An error "no type named 'type'" here means that the arguments to mp_assign aren't lists
0084 };
0085 
0086 template<template<class...> class L1, class... T, template<class...> class L2, class... U> struct mp_assign_impl<L1<T...>, L2<U...>>
0087 {
0088     using type = L1<U...>;
0089 };
0090 
0091 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0092 
0093 template<template<auto...> class L1, auto... A, template<class...> class L2, class... U> struct mp_assign_impl<L1<A...>, L2<U...>>
0094 {
0095     using type = L1<U::value...>;
0096 };
0097 
0098 template<template<class...> class L1, class... T, template<auto...> class L2, auto... B> struct mp_assign_impl<L1<T...>, L2<B...>>
0099 {
0100     using type = L1<mp_value<B>...>;
0101 };
0102 
0103 template<template<auto...> class L1, auto... A, template<auto...> class L2, auto... B> struct mp_assign_impl<L1<A...>, L2<B...>>
0104 {
0105     using type = L1<B...>;
0106 };
0107 
0108 #endif
0109 
0110 } // namespace detail
0111 
0112 template<class L1, class L2> using mp_assign = typename detail::mp_assign_impl<L1, L2>::type;
0113 
0114 // mp_clear<L>
0115 template<class L> using mp_clear = mp_assign<L, mp_list<>>;
0116 
0117 // mp_front<L>
0118 //   in detail/mp_front.hpp
0119 
0120 // mp_pop_front<L>
0121 namespace detail
0122 {
0123 
0124 template<class L> struct mp_pop_front_impl
0125 {
0126 // An error "no type named 'type'" here means that the argument to mp_pop_front
0127 // is either not a list, or is an empty list
0128 };
0129 
0130 template<template<class...> class L, class T1, class... T> struct mp_pop_front_impl<L<T1, T...>>
0131 {
0132     using type = L<T...>;
0133 };
0134 
0135 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0136 
0137 template<template<auto...> class L, auto A1, auto... A> struct mp_pop_front_impl<L<A1, A...>>
0138 {
0139     using type = L<A...>;
0140 };
0141 
0142 #endif
0143 
0144 } // namespace detail
0145 
0146 template<class L> using mp_pop_front = typename detail::mp_pop_front_impl<L>::type;
0147 
0148 // mp_first<L>
0149 template<class L> using mp_first = mp_front<L>;
0150 
0151 // mp_rest<L>
0152 template<class L> using mp_rest = mp_pop_front<L>;
0153 
0154 // mp_second<L>
0155 namespace detail
0156 {
0157 
0158 template<class L> struct mp_second_impl
0159 {
0160 // An error "no type named 'type'" here means that the argument to mp_second
0161 // is either not a list, or has fewer than two elements
0162 };
0163 
0164 template<template<class...> class L, class T1, class T2, class... T> struct mp_second_impl<L<T1, T2, T...>>
0165 {
0166     using type = T2;
0167 };
0168 
0169 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0170 
0171 template<template<auto...> class L, auto A1, auto A2, auto... A> struct mp_second_impl<L<A1, A2, A...>>
0172 {
0173     using type = mp_value<A2>;
0174 };
0175 
0176 #endif
0177 
0178 } // namespace detail
0179 
0180 template<class L> using mp_second = typename detail::mp_second_impl<L>::type;
0181 
0182 // mp_third<L>
0183 namespace detail
0184 {
0185 
0186 template<class L> struct mp_third_impl
0187 {
0188 // An error "no type named 'type'" here means that the argument to mp_third
0189 // is either not a list, or has fewer than three elements
0190 };
0191 
0192 template<template<class...> class L, class T1, class T2, class T3, class... T> struct mp_third_impl<L<T1, T2, T3, T...>>
0193 {
0194     using type = T3;
0195 };
0196 
0197 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0198 
0199 template<template<auto...> class L, auto A1, auto A2, auto A3, auto... A> struct mp_third_impl<L<A1, A2, A3, A...>>
0200 {
0201     using type = mp_value<A3>;
0202 };
0203 
0204 #endif
0205 
0206 } // namespace detail
0207 
0208 template<class L> using mp_third = typename detail::mp_third_impl<L>::type;
0209 
0210 // mp_push_front<L, T...>
0211 namespace detail
0212 {
0213 
0214 template<class L, class... T> struct mp_push_front_impl
0215 {
0216 // An error "no type named 'type'" here means that the first argument to mp_push_front is not a list
0217 };
0218 
0219 template<template<class...> class L, class... U, class... T> struct mp_push_front_impl<L<U...>, T...>
0220 {
0221     using type = L<T..., U...>;
0222 };
0223 
0224 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0225 
0226 template<template<auto...> class L, auto... A, class... T> struct mp_push_front_impl<L<A...>, T...>
0227 {
0228     using type = L<T::value..., A...>;
0229 };
0230 
0231 #endif
0232 
0233 } // namespace detail
0234 
0235 template<class L, class... T> using mp_push_front = typename detail::mp_push_front_impl<L, T...>::type;
0236 
0237 // mp_push_back<L, T...>
0238 namespace detail
0239 {
0240 
0241 template<class L, class... T> struct mp_push_back_impl
0242 {
0243 // An error "no type named 'type'" here means that the first argument to mp_push_back is not a list
0244 };
0245 
0246 template<template<class...> class L, class... U, class... T> struct mp_push_back_impl<L<U...>, T...>
0247 {
0248     using type = L<U..., T...>;
0249 };
0250 
0251 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0252 
0253 template<template<auto...> class L, auto... A, class... T> struct mp_push_back_impl<L<A...>, T...>
0254 {
0255     using type = L<A..., T::value...>;
0256 };
0257 
0258 #endif
0259 
0260 } // namespace detail
0261 
0262 template<class L, class... T> using mp_push_back = typename detail::mp_push_back_impl<L, T...>::type;
0263 
0264 // mp_rename<L, B>
0265 // mp_apply<F, L>
0266 // mp_apply_q<Q, L>
0267 //   in detail/mp_rename.hpp
0268 
0269 // mp_rename_v<L, B>
0270 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0271 
0272 namespace detail
0273 {
0274 
0275 template<class L, template<auto...> class B> struct mp_rename_v_impl
0276 {
0277 // An error "no type named 'type'" here means that the first argument to mp_rename_v is not a list
0278 };
0279 
0280 template<template<class...> class L, class... T, template<auto...> class B> struct mp_rename_v_impl<L<T...>, B>
0281 {
0282     using type = B<T::value...>;
0283 };
0284 
0285 template<template<auto...> class L, auto... A, template<auto...> class B> struct mp_rename_v_impl<L<A...>, B>
0286 {
0287     using type = B<A...>;
0288 };
0289 
0290 } // namespace detail
0291 
0292 template<class L, template<auto...> class B> using mp_rename_v = typename detail::mp_rename_v_impl<L, B>::type;
0293 
0294 #endif
0295 
0296 // mp_replace_front<L, T>
0297 namespace detail
0298 {
0299 
0300 template<class L, class T> struct mp_replace_front_impl
0301 {
0302 // An error "no type named 'type'" here means that the first argument to mp_replace_front
0303 // is either not a list, or is an empty list
0304 };
0305 
0306 template<template<class...> class L, class U1, class... U, class T> struct mp_replace_front_impl<L<U1, U...>, T>
0307 {
0308     using type = L<T, U...>;
0309 };
0310 
0311 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0312 
0313 template<template<auto...> class L, auto A1, auto... A, class T> struct mp_replace_front_impl<L<A1, A...>, T>
0314 {
0315     using type = L<T::value, A...>;
0316 };
0317 
0318 #endif
0319 
0320 } // namespace detail
0321 
0322 template<class L, class T> using mp_replace_front = typename detail::mp_replace_front_impl<L, T>::type;
0323 
0324 // mp_replace_first<L, T>
0325 template<class L, class T> using mp_replace_first = typename detail::mp_replace_front_impl<L, T>::type;
0326 
0327 // mp_replace_second<L, T>
0328 namespace detail
0329 {
0330 
0331 template<class L, class T> struct mp_replace_second_impl
0332 {
0333 // An error "no type named 'type'" here means that the first argument to mp_replace_second
0334 // is either not a list, or has fewer than two elements
0335 };
0336 
0337 template<template<class...> class L, class U1, class U2, class... U, class T> struct mp_replace_second_impl<L<U1, U2, U...>, T>
0338 {
0339     using type = L<U1, T, U...>;
0340 };
0341 
0342 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0343 
0344 template<template<auto...> class L, auto A1, auto A2, auto... A, class T> struct mp_replace_second_impl<L<A1, A2, A...>, T>
0345 {
0346     using type = L<A1, T::value, A...>;
0347 };
0348 
0349 #endif
0350 
0351 } // namespace detail
0352 
0353 template<class L, class T> using mp_replace_second = typename detail::mp_replace_second_impl<L, T>::type;
0354 
0355 // mp_replace_third<L, T>
0356 namespace detail
0357 {
0358 
0359 template<class L, class T> struct mp_replace_third_impl
0360 {
0361 // An error "no type named 'type'" here means that the first argument to mp_replace_third
0362 // is either not a list, or has fewer than three elements
0363 };
0364 
0365 template<template<class...> class L, class U1, class U2, class U3, class... U, class T> struct mp_replace_third_impl<L<U1, U2, U3, U...>, T>
0366 {
0367     using type = L<U1, U2, T, U...>;
0368 };
0369 
0370 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0371 
0372 template<template<auto...> class L, auto A1, auto A2, auto A3, auto... A, class T> struct mp_replace_third_impl<L<A1, A2, A3, A...>, T>
0373 {
0374     using type = L<A1, A2, T::value, A...>;
0375 };
0376 
0377 #endif
0378 
0379 } // namespace detail
0380 
0381 template<class L, class T> using mp_replace_third = typename detail::mp_replace_third_impl<L, T>::type;
0382 
0383 // mp_transform_front<L, F>
0384 namespace detail
0385 {
0386 
0387 template<class L, template<class...> class F> struct mp_transform_front_impl
0388 {
0389 // An error "no type named 'type'" here means that the first argument to mp_transform_front
0390 // is either not a list, or is an empty list
0391 };
0392 
0393 template<template<class...> class L, class U1, class... U, template<class...> class F> struct mp_transform_front_impl<L<U1, U...>, F>
0394 {
0395     using type = L<F<U1>, U...>;
0396 };
0397 
0398 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0399 
0400 template<template<auto...> class L, auto A1, auto... A, template<class...> class F> struct mp_transform_front_impl<L<A1, A...>, F>
0401 {
0402     using type = L<F<mp_value<A1>>::value, A...>;
0403 };
0404 
0405 #endif
0406 
0407 } // namespace detail
0408 
0409 template<class L, template<class...> class F> using mp_transform_front = typename detail::mp_transform_front_impl<L, F>::type;
0410 template<class L, class Q> using mp_transform_front_q = mp_transform_front<L, Q::template fn>;
0411 
0412 // mp_transform_first<L, F>
0413 template<class L, template<class...> class F> using mp_transform_first = typename detail::mp_transform_front_impl<L, F>::type;
0414 template<class L, class Q> using mp_transform_first_q = mp_transform_first<L, Q::template fn>;
0415 
0416 // mp_transform_second<L, F>
0417 namespace detail
0418 {
0419 
0420 template<class L, template<class...> class F> struct mp_transform_second_impl
0421 {
0422 // An error "no type named 'type'" here means that the first argument to mp_transform_second
0423 // is either not a list, or has fewer than two elements
0424 };
0425 
0426 template<template<class...> class L, class U1, class U2, class... U, template<class...> class F> struct mp_transform_second_impl<L<U1, U2, U...>, F>
0427 {
0428     using type = L<U1, F<U2>, U...>;
0429 };
0430 
0431 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0432 
0433 template<template<auto...> class L, auto A1, auto A2, auto... A, template<class...> class F> struct mp_transform_second_impl<L<A1, A2, A...>, F>
0434 {
0435     using type = L<A1, F<mp_value<A2>>::value, A...>;
0436 };
0437 
0438 #endif
0439 
0440 } // namespace detail
0441 
0442 template<class L, template<class...> class F> using mp_transform_second = typename detail::mp_transform_second_impl<L, F>::type;
0443 template<class L, class Q> using mp_transform_second_q = mp_transform_second<L, Q::template fn>;
0444 
0445 // mp_transform_third<L, F>
0446 namespace detail
0447 {
0448 
0449 template<class L, template<class...> class F> struct mp_transform_third_impl
0450 {
0451 // An error "no type named 'type'" here means that the first argument to mp_transform_third
0452 // is either not a list, or has fewer than three elements
0453 };
0454 
0455 template<template<class...> class L, class U1, class U2, class U3, class... U, template<class...> class F> struct mp_transform_third_impl<L<U1, U2, U3, U...>, F>
0456 {
0457     using type = L<U1, U2, F<U3>, U...>;
0458 };
0459 
0460 #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
0461 
0462 template<template<auto...> class L, auto A1, auto A2, auto A3, auto... A, template<class...> class F> struct mp_transform_third_impl<L<A1, A2, A3, A...>, F>
0463 {
0464     using type = L<A1, A2, F<mp_value<A3>>::value, A...>;
0465 };
0466 
0467 #endif
0468 
0469 } // namespace detail
0470 
0471 template<class L, template<class...> class F> using mp_transform_third = typename detail::mp_transform_third_impl<L, F>::type;
0472 template<class L, class Q> using mp_transform_third_q = mp_transform_third<L, Q::template fn>;
0473 
0474 } // namespace mp11
0475 } // namespace boost
0476 
0477 #if defined(_MSC_VER) || defined(__GNUC__)
0478 # pragma pop_macro( "I" )
0479 #endif
0480 
0481 #endif // #ifndef BOOST_MP11_LIST_HPP_INCLUDED