diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index ef7aa6a..fae2cf0 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -713,6 +713,32 @@ As `mp_fold`, but takes a quoted metafunction. As `mp_reverse_fold`, but takes a quoted metafunction. +## mp_partial_sum + + template class F> using mp_partial_sum = /*...*/; + +`mp_partial_sum` is similar to `mp_fold`, but instead of its final result, it returns +a list (of the same form as `L`) holding the intermediate results of the fold. The last element of the +result of `mp_partial_sum` is the same as the result of `mp_fold`. + +For example, `mp_fold, V, F>` is `F, X2>, X3>`, but +`mp_partial_sum, V, F>` is `mp_list, F, X2>, F, X2>, X3>>`. + +It's common for `F` to be `mp_plus`, in which case the result contains the partial sums of `L`. + +.Using mp_partial_sum +---- +using L1 = mp_list_c; +using R1 = mp_partial_sum, mp_plus>; // mp_list_c +---- + +## mp_partial_sum_q + + template using mp_partial_sum_q = + mp_partial_sum; + +As `mp_partial_sum`, but takes a quoted metafunction. + ## mp_unique template using mp_unique = /*...*/; diff --git a/doc/mp11/changelog.adoc b/doc/mp11/changelog.adoc index 76c2ade..098c59e 100644 --- a/doc/mp11/changelog.adoc +++ b/doc/mp11/changelog.adoc @@ -17,6 +17,7 @@ http://www.boost.org/LICENSE_1_0.txt * Added `mp_rotate_left`, `mp_rotate_right` (contributed by Duncan Barber) * Added `mp_compose` * Added `mp_power_set` +* Added `mp_partial_sum` ## Changes in 1.70.0