From 70ff01c85f20b1af5e2fee6c49ada1e30c1f36a9 Mon Sep 17 00:00:00 2001 From: Braden Ganetsky Date: Sun, 30 Jul 2023 12:48:11 -0500 Subject: [PATCH] Add mp_sliding_fold to the adoc file --- doc/mp11/algorithm.adoc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 95b9d73..a3b4553 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -846,6 +846,39 @@ template class P> using is_sorted = mp_none_of>, mp_to_bool>; ---- +## mp_sliding_fold + + template class F> using mp_sliding_fold = /*...*/; + +`mp_sliding_fold` returns a list of the same form as `L` whose elements are +the result of the application of the n-ary metafunction `F` to each n-tuple of adjacent +elements of `L`. That is, `mp_sliding_fold, mp_size_t<3>, F>` is +`L, F>`. + +The result has `N-1` fewer elements than the original. +If `L` has fewer than `N::value` elements, the result is an empty list. + +.Using mp_sliding_fold +---- +template using local_maximum = + mp_sliding_fold; +---- + +## mp_sliding_fold_q + + template using mp_sliding_fold_q = + mp_sliding_fold; + +As `mp_sliding_fold`, but takes a quoted metafunction. + +.Using mp_sliding_fold_q +---- +struct average { template using fn = mp_int::value / sizeof...(C)>; }; + +template using moving_average = + mp_sliding_fold_q; +---- + ## mp_iterate template class F, template class R>