//// Copyright 2017 Peter Dimov Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt //// [#utility] # Utility Components, :toc: :toc-title: :idprefix: ## mp_identity template struct mp_identity { using type = T; }; ## mp_identity_t template using mp_identity_t = T; ## mp_inherit template struct mp_inherit: T... {}; ## mp_if_c template using mp_if_c = /*...*/; `mp_if_c` is an alias for `T`. `mp_if_c` is an alias for `E`. Otherwise, the result is a substitution failure. using R1 = mp_if_c; // int using R2 = mp_if_c; // void template using void_if_5 = mp_if_c; // `void` when `I::value` is 5, substitution failure otherwise ## mp_if template using mp_if = mp_if_c(C::value), T, E...>; Like `mp_if_c`, but the first argument is a type. ## mp_eval_if_c template class F, class... U> using mp_eval_if_c = /*...*/; `mp_eval_if_c` is an alias for `T` when `C` is `true`, for `F` otherwise. Its purpose is to avoid evaluating `F` when the condition is `true` as it may not be valid in this case. ## mp_eval_if template class F, class... U> using mp_eval_if = mp_eval_if_c(C::value), T, F, U...>; Like `mp_eval_if_c`, but the first argument is a type. ## mp_eval_if_q template using mp_eval_if_q = mp_eval_if; Like `mp_eval_if`, 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. ## mp_defer template class F, class... T> using mp_defer = /*...*/; When `mp_valid` is `mp_true`, `mp_defer` is a struct with a nested type `type` which is an alias for `F`. Otherwise, `mp_defer` is an empty struct. ## mp_quote template class F> struct mp_quote { template using fn = F; }; `mp_quote` transforms the template `F` into a type with a nested template `fn` such that `fn` returns `F`. ## mp_invoke template using mp_invoke = typename Q::template fn; `mp_invoke` evaluates the nested template `fn` of a quoted metafunction. `mp_invoke, T...>` returns `F`.