template<template<class...> class F> struct mp_quote_trait +{ + template<class... T> using fn = typename F<T...>::type; +};+
diff --git a/doc/html/mp11.html b/doc/html/mp11.html index 09c746f..90b7f4b 100644 --- a/doc/html/mp11.html +++ b/doc/html/mp11.html @@ -487,6 +487,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
template<template<class...> class F> struct mp_quote_trait +{ + template<class... T> using fn = typename F<T...>::type; +};+
mp_quote_trait<F>
transforms the C++03-style trait F
into a quoted metafunction.
using L1 = mp_list<int, void, float>;
+using R1 = mp_transform_q<mp_quote_trait<std::add_pointer>, L1>;
+ // mp_list<int*, void*, float*>
+mp_invoke<Q, T…>
evaluates the nested template fn
of a quoted metafunction. mp_invoke<mp_quote<F>, T…>
returns F<T…>
.
using LQ = mp_list<mp_quote<std::is_const>, mp_quote<std::is_volatile>>;
@@ -2047,14 +2070,14 @@ template<class T> using is_const_and_volatile =
template<class T> using is_const_and_volatile =
mp_all<mp_transform_q<mp_bind_back<mp_invoke, T>, LQ>>;
template<class T> using is_const_and_volatile =
mp_all<mp_transform<mp_invoke, LQ, mp_fill<LQ, T>>>;
@@ -2075,7 +2098,7 @@ template<class T> using is_const_and_volatile =
mp_assign<L1<T1…>, L2<T2…>>
is an alias for L1<T2…>
. That is, it replaces the elements of L1
with those of L2
.
using L1 = std::tuple<long>;
using L2 = mp_list<int, float>;
@@ -2084,7 +2107,7 @@ using R1 = mp_assign<L1, L2>; // std::tuple<int, float>
using L1 = std::pair<long, char>;
using L2 = mp_list<int, float>;
@@ -2143,7 +2166,7 @@ using R1 = mp_assign<L1, L2>; // std::pair<int, float>
mp_clear<L<T…>>
is an alias for L<>
, that is, it removes the elements of L
.
using L1 = std::tuple<int, float>;
using R1 = mp_clear<L1>; // std::tuple<>
@@ -2161,7 +2184,7 @@ using R1 = mp_clear<L1>; // std::tuple<>
mp_transform<F, L1<T1…>, L2<T2…>, …, Ln<Tn…>>
applies F
to each successive tuple of elements and returns L1<F<T1, T2, …, Tn>…>
.
template<class T> using add_pointer_t =
typename std::add_pointer<T>::type; // std::add_pointer_t in C++14
@@ -2171,7 +2194,7 @@ using R1 = mp_transform<add_pointer_t, L1>; // std::tuple<void*, int*,
using L1 = std::tuple<void, int, float>;
using L2 = mp_list<void, int, float>;
@@ -2180,7 +2203,7 @@ using R1 = mp_all<mp_transform<std::is_same, L1, L2>>; // mp_true
template<class T1, class T2> using eq = mp_bool<T1::value == T2::value>;
@@ -2271,7 +2294,7 @@ using R1 = mp_all<mp_transform<eq, L1, L2>>; // mp_true
As mp_transform
, but takes a quoted metafunction.
void
in a listvoid
in a listusing L1 = std::tuple<void, int, float, void, int>;
@@ -2332,7 +2355,7 @@ using R1 = mp_apply<mp_plus,
F<T1, T2, …, Tn>
, and returns the result, where Ti
are the corresponding elements of Li
.
using L1 = std::tuple<void, int, float, void, int>;
using L2 = std::tuple<char[1], char[2], char[3], char[4], char[5]>;
@@ -2406,7 +2429,7 @@ using R1 = mp_transform_if<first_is_void, second, L1, L2>;
As mp_transform_if
, but takes quoted metafunctions.
using L1 = std::tuple<void, int, float, void, int>;
using L2 = std::tuple<char[1], char[2], char[3], char[4], char[5]>;
@@ -2476,14 +2499,14 @@ using R1 = mp_transform_if_q<mp_bind<std::is_same, _1, void>, _2, L1, L
mp_fill<L<T…>, V>
returns L<V, V, …, V>
, with the result having the same size as the input.
using L1 = std::tuple<void, int, float>;
using R1 = mp_fill<L1, double>; // std::tuple<double, double, double>
using L1 = std::pair<int, float>;
using R1 = mp_fill<L1, void>; // std::pair<void, void>
@@ -3128,7 +3151,7 @@ for the elements of L<U1…>
and mp_falsemp_sort<L, P>
sorts the list L
according to the strict weak ordering mp_to_bool<P<T, U>>
.
#include <ratio> @@ -3213,7 +3236,7 @@ ismp_size<L>
.
mp_fold<L<T1, T2, …, Tn>, V, F>
isF< F< F< F<V, T1>, T2>, …>, Tn>
, orV
, ifL
is empty.
#include <ratio> @@ -3295,7 +3318,7 @@ using R1 = mp_fold<L1, std::ratio<0,1>, std::ratio_add>; // std::ratReturns
std::forward<F>(f)
.
template<class... T> void print( std::tuple<T...> const & tp )
{
@@ -3336,7 +3359,7 @@ Only constexpr
on C++14 and higher.
Returns mp_with_index<N::value>(i, f)
.
template<class... T> void print( std::variant<T...> const& v )
{
@@ -3493,7 +3516,7 @@ returns mp_false
. If the application causes a substitution failure,
returns mp_true
. mp_and<>
is mp_true
.
using R1 = mp_and<mp_true, mp_true>; // mp_true
@@ -3519,7 +3542,7 @@ is an error because void
does not have a nested value
.
mask substitution failures as mp_and
does.
using R1 = mp_all<mp_true, mp_true>; // mp_true
@@ -3543,7 +3566,7 @@ using R4 = mp_all<void, mp_true>; // compile-time error
returns mp_true
. If all results are mp_false
, returns mp_false
. mp_or<>
is mp_false
.
using R1 = mp_or<mp_true, mp_false>; // mp_true
@@ -3567,7 +3590,7 @@ using R4 = mp_or<void, mp_true>; // compile-time error
mp_or
, but does not perform short-circuit evaluation.
using R1 = mp_any<mp_true, mp_false>; // mp_true
diff --git a/doc/mp11/utility.adoc b/doc/mp11/utility.adoc
index 2488986..eabab3e 100644
--- a/doc/mp11/utility.adoc
+++ b/doc/mp11/utility.adoc
@@ -169,6 +169,22 @@ When `mp_valid` is `mp_true`, `mp_defer` is a struct with a ne
using LQ = mp_list, mp_quote>;
```
+## mp_quote_trait
+
+ template class F> struct mp_quote_trait
+ {
+ template using fn = typename F::type;
+ };
+
+`mp_quote_trait` transforms the C++03-style trait `F` into a quoted metafunction.
+
+.Using mp_quote_trait with std::add_pointer
+```
+using L1 = mp_list;
+using R1 = mp_transform_q, L1>;
+ // mp_list
+```
+
## mp_invoke
template using mp_invoke = typename Q::template fn;