|
Boost : |
Subject: Re: [boost] [review][mp11] Formal review of Mp11
From: Fletcher, John P (j.p.fletcher_at_[hidden])
Date: 2017-07-19 15:38:34
Here is my review of MP11.
1. Should Mp11 be accepted into Boost? Please state all conditions for acceptance explicity.
Yes I think it should be accepted. There are changes I would like to see to the documentation. I dont regard those as setting a condition on acceptance.
2. What is your evaluation of the design?
I like the design which is consistent and clear. I have found it easy to understand.
3. What is your evaluation of the implementation?
The implementation is also clear and consistent. I have found it easy to understand and to develop extensions to cover cases not in the implementation.
4. What is your evaluation of the documentation?
I have had some problems with the documentation. Some of these came up when I attempted to use the examples and found that not all of the example code was C++11 compatible. I found ways around this and I believe that this has now been sorted out.
Some items e.g. mp_identity_t<T> and mp_inherit<T
> have no documentation other that a code line and no example.
I think there is a need for more examples in some areas.
5. What is your evaluation of the potential usefulness of the library?
I think there is a great potential for this. I particularly like mp_quote_trait<F> and mp_invoke<Q,T
> which have many uses to simplify the implementation of type deduction, particularly of return types from functions. This is an area which has not been discussed much in the course of the review.
6. Did you try to use the library? With what compiler? Did you have
any problems?
I have used the library mainly with Clang 4.0 and also with gcc 4.9.2 working on Linux.
My initial problems were getting some examples to work with C++11. This is mainly the extra things which are in std for C++14. I overcame these in most cases using mp_quote_trait<F> which gave code which works with C++11 and C++14.
I have gone on to reimplement some code which does fairly complicated operations to get return types. I used mp_quote_trait<F> and mp_invoke<Q,T
> and removed all of the ::type code from my new code.
I have also written extensions to mp_quote_trait to allow for the case where the inner function is of the form F<int N,T
>.
I wanted this to allow F to be called with the contents of a list L<T
> for cases N = 1,2,3 corresponding to the number of arguments of F. For this it is necessary to call specialisations of a helper function. The code is like this, where I have defined mp_inside_N to allow access to T
// Extensions to MP11 invented to handle case with int N at start of types.
template<template<int, class...> class F> struct mp_quote_trait_N {
template<int N, class... T> using fn = typename F<N, T...>::type;
};
template<class Q, int N, class... TN> using mp_invoke_N = typename Q::template fn<N,TN...>;
// mp_inside_N allows operations to work on the pack inside the list.
// This applies mp_invoke_N and is the case I need here.
template <class Q,class FF,class LL> struct mp_inside_N;
template <class Q,class FF, template<class...> class L, class... TL>
struct mp_inside_N <Q,FF,L<TL...> > {
typedef mp_invoke_N<Q,sizeof...(TL),FF,TL...> type;
};
using mp_q_inside_N_t = mp_quote_trait<mp_inside_N>;
// usage, where RTHelper is the helper struct e.g.
template <int N, typename FF, typename... XYZ> struct RTHelper;
template <typename FF,typename A> struct RTHelper <1,FF,A> {
typedef mp_invoke<mp_q_result_of_t,FF(A)> type;
}; // and for N=2,3 etc as needed.
using mp_q_RTHelper_t = mp_quote_trait_N<RTHelper>;
typedef mp_invoke<mp_q_inside_N_t,mp_q_RTHelper_t,FType,ArgTypes> ReturnType;
I have not used MP11 yet to write new code which I did not have before.
7. How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
I have worked for some hours for several days getting an understanding and implementing examples.
8. Are you knowledgeable about the problem domain?
I have worked for a period of years on templated code, from FC++ to Boost Phoenix. I have written some variadic codes. I am not so knowledgeable about C++14. I have explored other new libraries including Hana.
I appreciate this code and expect to go on using it. Thank you to Peter for contributing it.
John Fletcher
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk