]> git.lyx.org Git - lyx.git/blob - 3rdparty/boost/boost/mp11/detail/mp_fold.hpp
Update to boost 1.72
[lyx.git] / 3rdparty / 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/mp11/detail/config.hpp>
12
13 namespace boost
14 {
15 namespace mp11
16 {
17
18 // mp_fold<L, V, F>
19 namespace detail
20 {
21
22 template<class L, class V, template<class...> class F> struct mp_fold_impl
23 {
24 // An error "no type named 'type'" here means that the first argument to mp_fold is not a list
25 };
26
27 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
28
29 template<template<class...> class L, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T...>, V, F>
30 {
31     static_assert( sizeof...(T) == 0, "T... must be empty" );
32     using type = V;
33 };
34
35 #else
36
37 template<template<class...> class L, class V, template<class...> class F> struct mp_fold_impl<L<>, V, F>
38 {
39     using type = V;
40 };
41
42 #endif
43
44 template<template<class...> class L, class T1, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T1, T...>, V, F>
45 {
46     using type = typename mp_fold_impl<L<T...>, F<V, T1>, F>::type;
47 };
48
49 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>
50 {
51     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;
52 };
53
54 } // namespace detail
55
56 template<class L, class V, template<class...> class F> using mp_fold = typename detail::mp_fold_impl<L, V, F>::type;
57 template<class L, class V, class Q> using mp_fold_q = mp_fold<L, V, Q::template fn>;
58
59 } // namespace mp11
60 } // namespace boost
61
62 #endif // #ifndef BOOST_MP11_DETAIL_MP_FOLD_HPP_INCLUDED