1
0
forked from boostorg/mp11
Files
boost_mp11/doc/mp11/utility.qbk
2017-03-20 16:23:52 +02:00

81 lines
2.8 KiB
Plaintext

[/
/ 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)
/]
[section:utility Utility Components, `<boost/mp11/utility.hpp>`]
[section `mp_identity<T>`]
template<class T> struct mp_identity
{
using type = T;
};
[endsect]
[section `mp_identity_t<T>`]
template<class T> using mp_identity_t = T;
[endsect]
[section `mp_inherit<T...>`]
template<class... T> struct mp_inherit: T... {};
[endsect]
[section `mp_if_c<B, T, E>`]
template<bool C, class T, class E> using mp_if_c = /*...*/;
`mp_if_c<B, T, E>` is an alias for `T` when `B` is `true`, for `E` otherwise.
[endsect]
[section `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>;
`mp_if<C, T, E>` is an alias for `T` when `C::value` is `true`, for `E` otherwise.
[endsect]
[section `mp_eval_if_c<B, T, F, U...>`]
template<bool C, class T, template<class...> class F, class... U> using mp_eval_if_c = /*...*/;
`mp_eval_if_c<B, T, F, U...>` is an alias for `T` when `B` 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.
[endsect]
[section `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.
[endsect]
[section `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.
[endsect]
[section `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.
[endsect]
[section `mp_quote<F, T...>`]
template<template<class...> class F, class... T> struct mp_quote
{
template<class... U> using fn = F<T..., U...>;
};
`mp_quote<F, T...>` transforms the template `F` into a type. In the common case `mp_quote<F>`, the nested template `fn` of the result is an alias for `F`;
otherwise, `fn<U...>` is an alias for `F<T..., U...>`, allowing partial application.
[endsect]
[section `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...>` is an alias for `F<T...>`. `mp_invoke<mp_quote<F, T...>, U...>` is an alias for `F<T..., U...>`.
[endsect]
[endsect]