diff --git a/doc/mp11/utility.adoc b/doc/mp11/utility.adoc index eabab3e..c32f11d 100644 --- a/doc/mp11/utility.adoc +++ b/doc/mp11/utility.adoc @@ -22,7 +22,7 @@ http://www.boost.org/LICENSE_1_0.txt `mp_identity` is a simple _transformation type trait_ (as per the C++ standard) that just returns the same type. It's useful both as such, and as a type wrapper -useful for passing types as values to functions. +for passing types as values to functions. .Using mp_identity as a type trait ``` @@ -135,6 +135,27 @@ template using first_or_void = mp_eval_if, void, mp_first, Like `mp_eval_if`, but takes a quoted metafunction. +## mp_cond + + template using mp_cond = /*...*/; + +`mp_cond` is an alias for `T` when `static_cast(C::value)` is `true`. +When `static_cast(C::value)` is `false`, it's an alias for `mp_cond`. + +(If `static_cast(C::value)` is a substitution failure, the result is too a substitution +failure.) + +.Using mp_cond +``` +template using unsigned_ = mp_cond< + mp_bool, uint8_t, + mp_bool, uint16_t, + mp_bool, uint32_t, + mp_bool, uint64_t, + mp_true, unsigned // default case +>; +``` + ## mp_valid template class F, class... T> using mp_valid = /*...*/;