////
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, <boost/mp11/utility.hpp>
:toc:
:idprefix:

## mp_identity<T>

    template<class T> struct mp_identity
    {
        using type = T;
    };

## mp_identity_t<T>

    template<class T> using mp_identity_t = T;

## mp_inherit<T...>

    template<class... T> struct mp_inherit: T... {};

## mp_if_c<C, T, E...>

    template<bool C, class T, class... E> using mp_if_c = /*...*/;

`mp_if_c<true, T, E...>` is an alias for `T`. `mp_if_c<false, T, E>` is an alias for `E`. Otherwise, the result is a substitution failure.

    using R1 = mp_if_c<true, int, void>;  // int
    using R2 = mp_if_c<flase, int, void>; // void

	template<class I> using void_if_5 = mp_if_c<I::value == 5, void>; // `void` when `I::value` is 5, substitution failure otherwise

## mp_if<C, T, E...>

    template<class C, class T, class E...> using mp_if = mp_if_c<static_cast<bool>(C::value), T, E...>;

Like `mp_if_c`, but the first argument is a type.

## mp_eval_if_c<C, T, F, U...>

    template<bool C, class T, template<class...> class F, class... U> using mp_eval_if_c = /*...*/;

`mp_eval_if_c<C, T, F, U...>` is an alias for `T` when `C` is `true`, for `F<U...>` otherwise. Its purpose
is to avoid evaluating `F<U...>` when the condition is `true` as it may not be valid in this case.

## mp_eval_if<C, T, F, U...>

    template<class C, class T, template<class...> class F, class... U> using mp_eval_if = mp_eval_if_c<static_cast<bool>(C::value), T, F, U...>;

Like `mp_eval_if_c`, but the first argument is a type.

## mp_eval_if_q<C, T, Q, U...>

    template<class C, class T, class Q, class... U> using mp_eval_if_q = mp_eval_if<C, T, Q::template fn, U...>;

Like `mp_eval_if`, but takes a quoted metafunction.

## mp_valid<F, T...>

    template<template<class...> class F, class... T> using mp_valid = /*...*/;

`mp_valid<F, T...>` is an alias for `mp_true` when `F<T...>` is a valid expression, for `mp_false` otherwise.

## mp_defer<F, T...>

    template<template<class...> class F, class... T> using mp_defer = /*...*/;

When `mp_valid<F, T...>` is `mp_true`, `mp_defer<F, T...>` is a struct with a nested type `type` which is an alias for `F<T...>`. Otherwise,
`mp_defer<F, T...>` is an empty struct.

## mp_quote<F>

    template<template<class...> class F> struct mp_quote
    {
        template<class... T> using fn = F<T...>;
    };

`mp_quote<F>` transforms the template `F` into a type with a nested template `fn` such that `fn<T...>` returns `F<T...>`.

## mp_invoke<Q, T...>

    template<class Q, class... T> using mp_invoke = typename Q::template fn<T...>;

`mp_invoke<Q, T...>` evaluates the nested template `fn` of a quoted metafunction. `mp_invoke<mp_quote<F>, T...>` returns `F<T...>`.
