1
0
forked from boostorg/mp11

Document mp_partial_sum

This commit is contained in:
Peter Dimov
2020-03-19 19:35:02 +02:00
parent e9684a1f66
commit 5267548813
2 changed files with 27 additions and 0 deletions

View File

@@ -713,6 +713,32 @@ As `mp_fold`, but takes a quoted metafunction.
As `mp_reverse_fold`, but takes a quoted metafunction.
## mp_partial_sum<L, V, F>
template<class L, class V, template<class...> class F> using mp_partial_sum = /*...*/;
`mp_partial_sum<L, V, F>` is similar to `mp_fold<L, V, F>`, 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<mp_list<X1, X2, X3>, V, F>` is `F<F<F<V, X1>, X2>, X3>`, but
`mp_partial_sum<mp_list<X1, X2, X3>, V, F>` is `mp_list<F<V, X1>, F<F<V, X1>, X2>, F<F<F<V, X1>, 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<int, 1, 2, 3, 4>;
using R1 = mp_partial_sum<L1, mp_int<0>, mp_plus>; // mp_list_c<int, 1, 3, 6, 10>
----
## mp_partial_sum_q<L, V, Q>
template<class L, class V, class Q> using mp_partial_sum_q =
mp_partial_sum<L, V, Q::template fn>;
As `mp_partial_sum`, but takes a quoted metafunction.
## mp_unique<L>
template<class L> using mp_unique = /*...*/;

View File

@@ -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