]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/mp11/detail/mp_fold.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / mp11 / detail / mp_fold.hpp
1 #ifndef BOOST_MP11_DETAIL_MP_FOLD_HPP_INCLUDED
2 #define BOOST_MP11_DETAIL_MP_FOLD_HPP_INCLUDED
3
4 // Copyright 2015-2017 Peter Dimov.
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 //
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
10
11 #include <boost/config.hpp>
12 #include <boost/detail/workaround.hpp>
13
14 namespace boost
15 {
16 namespace mp11
17 {
18
19 // mp_fold<L, V, F>
20 namespace detail
21 {
22
23 template<class L, class V, template<class...> class F> struct mp_fold_impl
24 {
25 // An error "no type named 'type'" here means that the first argument to mp_fold is not a list
26 };
27
28 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
29
30 template<template<class...> class L, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T...>, V, F>
31 {
32 static_assert( sizeof...(T) == 0, "T... must be empty" );
33 using type = V;
34 };
35
36 #else
37
38 template<template<class...> class L, class V, template<class...> class F> struct mp_fold_impl<L<>, V, F>
39 {
40 using type = V;
41 };
42
43 #endif
44
45 template<template<class...> class L, class T1, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T1, T...>, V, F>
46 {
47 using type = typename mp_fold_impl<L<T...>, F<V, T1>, F>::type;
48 };
49
50 template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>, V, F>
51 {
52 using type = typename mp_fold_impl<L<T...>, F<F<F<F<F<F<F<F<F<F<V, T1>, T2>, T3>, T4>, T5>, T6>, T7>, T8>, T9>, T10>, F>::type;
53 };
54
55 } // namespace detail
56
57 template<class L, class V, template<class...> class F> using mp_fold = typename detail::mp_fold_impl<L, V, F>::type;
58 template<class L, class V, class Q> using mp_fold_q = mp_fold<L, V, Q::template fn>;
59
60 } // namespace mp11
61 } // namespace boost
62
63 #endif // #ifndef BOOST_MP11_DETAIL_MP_FOLD_HPP_INCLUDED