Le 17/03/2017 à 15:06, Peter Dimov via Boost a écrit :
I'd like to request a review for mp11, a simple C++11 metaprogramming
library.
The library implements the approach outlined in my two articles
http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html
http://pdimov.com/cpp2/simple_cxx11_metaprogramming_2.html
and is available at
https://github.com/pdimov/mp11/
There is documentation in doc/html/mp11.html, it can be viewed
locally, or with
https://htmlpreview.github.io/?https://github.com/pdimov/mp11/master/doc/htm...
Please excuse the lack of .css in that link.
Thanks in advance for any interest, comments or suggestions.
Hi,
I believe that there is a missing tutorial/design rationale section that
could be filled with some parts of your articles.
About the infamous tuple_cat challenge. tuple_cat doesn't append. tuple
cat construct a tuple with the elements of its tuple-like parameters (I
know that the standard wording doesn't says that exactly, as it accepts
only standard tuple-like types - I've written a proposal so that it can
take in account any product type including every type that is supported
by structure binding. See
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0327r1.pdf).
Examples of product types that don't follow the template aliases pattern
are T[N], array, struct {...};
I'm not saying that mp_append is not useful and it surely is much more
efficient, but the description in your paper doesn't solves yet the
problem with concatenation of arbitrary product types. We would need to
obtain to obtain the type list associated to to each product type, then
append them and the rename to tuple.
About transform. I believe that we should have a simple unary
transform. What you have mp11::transform is what we use to name
fmap in functional languages.
As C++ is variadic it can be extended naturally to variadic meta-functions.
mp_fmap, TLs...>.
About your mp_count example. Compare your definition with this the HOF one
template
using mp_count_if = mp_plus;
template
using mp_count = mp_cont_if>;
I don't know if this could have worst or better performances, but IMHO,
it is much more readable and simpler than your definitions.
BTW, your mp_plus doesn't take a type list as parameter.
About mp_contains. I've not yet finished the second article yet. IMO, we
need different concepts as we can have different implementations. I
believe mp_contains is an example where we can have different
implementations for type list and for type set. I recognize however that
most of the meta-programming is done with type lists.
About C++11, C++14, C++17. I believe that meta-programming can profit a
lot of C++17 fold expressions. I believe that a new meta library should
use these features as implementation details when available and when the
performances are increased.
Best,
Vicente