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
  • mp_valid<F, T…​>
  • mp_defer<F, T…​>
  • mp_quote<F>
  • +
  • mp_quote_trait<F>
  • mp_invoke<Q, T…​>
  • @@ -2028,6 +2029,28 @@ template<class T> struct has_nested_type: mp_valid<get_nested_type, T&g
    +

    mp_quote_trait<F>

    +
    +
    +
    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.

    +
    +
    +
    Code Example 42. Using mp_quote_trait with std::add_pointer
    +
    +
    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…​>

    @@ -2038,7 +2061,7 @@ template<class T> struct has_nested_type: mp_valid<get_nested_type, T&g

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

    -
    Code Example 42. Using mp_invoke to invoke a list of metafunctions, technique 1
    +
    Code Example 43. Using mp_invoke to invoke a list of metafunctions, technique 1
    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 =
     
    -
    Code Example 43. Using mp_invoke to invoke a list of metafunctions, technique 2
    +
    Code Example 44. Using mp_invoke to invoke a list of metafunctions, technique 2
    template<class T> using is_const_and_volatile =
         mp_all<mp_transform_q<mp_bind_back<mp_invoke, T>, LQ>>;
    -
    Code Example 44. Using mp_invoke to invoke a list of metafunctions, technique 3
    +
    Code Example 45. Using mp_invoke to invoke a list of metafunctions, technique 3
    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.

    -
    Code Example 45. Using mp_assign with mp_list and std::tuple
    +
    Code Example 46. Using mp_assign with mp_list and std::tuple
    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>
    -
    Code Example 46. Using mp_assign with mp_list and std::pair
    +
    Code Example 47. Using mp_assign with mp_list and std::pair
    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.

    -
    Code Example 47. Using mp_clear with std::tuple
    +
    Code Example 48. Using mp_clear with std::tuple
    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>…​>.

    -
    Code Example 48. Using mp_transform to produce a list of pointers from a list of pointees
    +
    Code Example 49. Using mp_transform to produce a list of pointers from a list of pointees
    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*,
     
    -
    Code Example 49. Using mp_transform to compare the contents of two lists of types
    +
    Code Example 50. Using mp_transform to compare the contents of two lists of types
    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
     
    -
    Code Example 50. Using mp_transform to compare the contents of two lists of integral constants
    +
    Code Example 51. Using mp_transform to compare the contents of two lists of integral constants
    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.

    -
    Code Example 51. Using mp_transform_q to count the occurences of void in a list
    +
    Code Example 52. Using mp_transform_q to count the occurences of void in a list
    using 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.

    -
    Code Example 52. Using mp_transform_if to replace the occurences of 'void' in a list with the corresponding elements of a second list
    +
    Code Example 53. Using mp_transform_if to replace the occurences of 'void' in a list with the corresponding elements of a second list
    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.

    -
    Code Example 53. Using mp_transform_if_q to replace the occurences of 'void' in a list with the corresponding elements of a second list
    +
    Code Example 54. Using mp_transform_if_q to replace the occurences of 'void' in a list with the corresponding elements of a second list
    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.

    -
    Code Example 54. Using mp_fill with std::tuple
    +
    Code Example 55. Using mp_fill with std::tuple
    using L1 = std::tuple<void, int, float>;
     using R1 = mp_fill<L1, double>; // std::tuple<double, double, double>
    -
    Code Example 55. Using mp_fill with std::pair
    +
    Code Example 56. Using mp_fill with std::pair
    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>>.

    -
    Code Example 56. Using mp_sort to sort a list of std::ratio values
    +
    Code Example 57. Using mp_sort to sort a list of std::ratio values
    #include <ratio>
     
    @@ -3213,7 +3236,7 @@ is mp_size<L>.

    mp_fold<L<T1, T2, …​, Tn>, V, F> is F< F< F< F<V, T1>, T2>, …​>, Tn>, or V, if L is empty.

    -
    Code Example 57. Using mp_fold to add the contents of a list of std::ratio values
    +
    Code Example 58. Using mp_fold to add the contents of a list of std::ratio values
    #include <ratio>
     
    @@ -3295,7 +3318,7 @@ using R1 = mp_fold<L1, std::ratio<0,1>, std::ratio_add>; // std::rat
     

    Returns std::forward<F>(f).

    -
    Code Example 58. Using mp_for_each and a C++14 lambda to print a tuple
    +
    Code Example 59. Using mp_for_each and a C++14 lambda to print a tuple
    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).

    -
    Code Example 59. Using mp_with_index and a C++14 lambda to print the active element of a variant
    +
    Code Example 60. Using mp_with_index and a C++14 lambda to print the active element of a variant
    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.

    -
    Code Example 60. mp_and behavior
    +
    Code Example 61. mp_and behavior
    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.

    -
    Code Example 61. mp_all behavior
    +
    Code Example 62. mp_all behavior
    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.

    -
    Code Example 62. mp_or behavior
    +
    Code Example 63. mp_or behavior
    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.

    -
    Code Example 63. mp_any behavior
    +
    Code Example 64. mp_any behavior
    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;