From d2b96e3a3f6d2165140c61965909a3516309009f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 15 Feb 2019 03:09:07 +0200 Subject: [PATCH] Document mp_eval_if_not, mp_eval_or, mp_valid_q --- doc/mp11.adoc | 2 +- doc/mp11/changelog.adoc | 1 + doc/mp11/utility.adoc | 64 +++++++++++++++++++++++++++++++---------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/doc/mp11.adoc b/doc/mp11.adoc index 24b3d13..748001a 100644 --- a/doc/mp11.adoc +++ b/doc/mp11.adoc @@ -35,7 +35,7 @@ include::mp11/reference.adoc[] This documentation is -* Copyright 2017 Peter Dimov +* Copyright 2017-2019 Peter Dimov * Copyright 2017 Bjørn Reese and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0]. diff --git a/doc/mp11/changelog.adoc b/doc/mp11/changelog.adoc index 577b1f4..69ece4a 100644 --- a/doc/mp11/changelog.adoc +++ b/doc/mp11/changelog.adoc @@ -18,6 +18,7 @@ http://www.boost.org/LICENSE_1_0.txt * Add `mp_not_fn` * Add `mp_transform_first`, `mp_transform_second`, `mp_transform_third` * Add `mp_filter` +* Add `mp_eval_if_not`, `mp_eval_or`, `mp_valid_q` ## Changes in 1.69.0 diff --git a/doc/mp11/utility.adoc b/doc/mp11/utility.adoc index bb6826d..fcd1a61 100644 --- a/doc/mp11/utility.adoc +++ b/doc/mp11/utility.adoc @@ -1,5 +1,5 @@ //// -Copyright 2017 Peter Dimov +Copyright 2017, 2019 Peter Dimov Distributed under the Boost Software License, Version 1.0. @@ -135,6 +135,53 @@ template using first_or_void = mp_eval_if, void, mp_first, Like `mp_eval_if`, but takes a quoted metafunction. +## mp_eval_if_not + + template class F, class... U> + using mp_eval_if_not = mp_eval_if, T, F, U...>; + +Same as `mp_eval_if`, but the condition is reversed. + +## mp_eval_if_not_q + + template using mp_eval_if_not_q = + mp_eval_if_not; + +Same as `mp_eval_if_not`, but takes a quoted metafunction. + +## mp_valid + + template class F, class... T> using mp_valid = /*...*/; + +`mp_valid` is an alias for `mp_true` when `F` is a valid expression, for `mp_false` otherwise. + +.Using mp_valid to write a metafunction that checks for the existence of a nested type +``` +template using get_nested_type = typename T::type; + +template struct has_nested_type: mp_valid {}; +``` + +## mp_valid_q + + template using mp_valid_q = mp_valid; + +Like `mp_valid`, but takes a quoted metafunction. + +## mp_eval_or + + template class F, class... U> using mp_eval_or = + mp_eval_if_not, T, F, U...>; + +`mp_eval_or` is an alias for `F` when this expression is valid, for `T` otherwise. + +## mp_eval_or_q + + template using mp_eval_or_q = + mp_eval_or; + +Like `mp_eval_or`, but takes a quoted metafunction. + ## mp_cond template using mp_cond = /*...*/; @@ -156,19 +203,6 @@ template using unsigned_ = mp_cond< >; ``` -## mp_valid - - template class F, class... T> using mp_valid = /*...*/; - -`mp_valid` is an alias for `mp_true` when `F` is a valid expression, for `mp_false` otherwise. - -.Using mp_valid to write a metafunction that checks for the existence of a nested type -``` -template using get_nested_type = typename T::type; - -template struct has_nested_type: mp_valid {}; -``` - ## mp_defer template class F, class... T> using mp_defer = /*...*/; @@ -183,7 +217,7 @@ When `mp_valid` is `mp_true`, `mp_defer` is a struct with a ne template using fn = F; }; -`mp_quote` transforms the template `F` into a type with a nested template `fn` such that `fn` returns `F`. +`mp_quote` transforms the template `F` into a _quoted metafunction_, a type with a nested template `fn` such that `fn` returns `F`. .Using mp_quote to make a list of metafunctions ```