From 2d0567d98477c086a4a23f81daddc30aa6fe9c64 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 5 Feb 2019 18:33:27 +0200 Subject: [PATCH] Document mp_filter --- doc/mp11/algorithm.adoc | 23 +++++++++++++++++++++++ doc/mp11/changelog.adoc | 1 + 2 files changed, 24 insertions(+) diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 8f53163..beecbe8 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -149,6 +149,29 @@ using R1 = mp_transform_if_q, _2, L1, L2>; |*mp_transform_if_q*|A~1~|B~2~|...|A~n~ |=== +## mp_filter + + template class P, class... L> using mp_filter = /*...*/; + +`mp_filter` removes the elements of the list `L1` for which `mp_to_bool>` +is `mp_false` and returns the result, where `Ti` are the corresponding elements of `Li`. + +See also `mp_copy_if` and `mp_remove_if`, less general variants of `mp_filter` that only take a single list. + +## mp_filter_q + + template using mp_filter_q = + mp_filter; + +As `mp_filter`, but takes quoted metafunctions. + +.Using mp_filter_q to pick elements of a list based on a mask in another list +``` +using L1 = std::tuple; +using L2 = mp_list; +using R1 = mp_filter_q<_2, L1, L2>; // std::tuple +``` + ## mp_fill template using mp_fill = /*...*/; diff --git a/doc/mp11/changelog.adoc b/doc/mp11/changelog.adoc index 486fa91..577b1f4 100644 --- a/doc/mp11/changelog.adoc +++ b/doc/mp11/changelog.adoc @@ -17,6 +17,7 @@ http://www.boost.org/LICENSE_1_0.txt * Add `mp_set_union`, `mp_set_intersection`, `mp_set_difference` * Add `mp_not_fn` * Add `mp_transform_first`, `mp_transform_second`, `mp_transform_third` +* Add `mp_filter` ## Changes in 1.69.0