From 247ffe8afe9c7fb119cb095e3d57a84c8b3d58d4 Mon Sep 17 00:00:00 2001 From: Braden Ganetsky Date: Sun, 30 Jul 2023 12:12:10 -0500 Subject: [PATCH] Add mp_sliding_fold --- include/boost/mp11/algorithm.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index be377f5..b58ce12 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -1261,6 +1261,27 @@ template using mp_pairwise_fold_impl = mp_transform_q using mp_pairwise_fold_q = mp_eval_if, mp_clear, detail::mp_pairwise_fold_impl, L, Q>; template class F> using mp_pairwise_fold = mp_pairwise_fold_q>; +// mp_sliding_fold +namespace detail +{ + +template struct mp_sliding_fold_impl; + +template struct mp_sliding_fold_impl> +{ + using type = mp_transform_q::value - (sizeof...(Ints) - Ints - 1)>, Ints>...>; +}; + +template struct mp_sliding_fold_impl +{ + using type = mp_clear; +}; + +} // namespace detail + +template using mp_sliding_fold_q = typename detail::mp_sliding_fold_impl::value >= N::value>, L, Q, make_index_sequence>::type; +template class F> using mp_sliding_fold = mp_sliding_fold_q>; + // mp_intersperse namespace detail {