:new: Add `mp_quote_expr` to quote with lambda expressions
Problem:
- There is no easy way to quote metafunction directly with lambda expressions.
Solution:
- Add mp_quote_expr.
Note:
- mp_quote_expr requires C++20.
@pdimov would you be able to take a look, please?
Do you have an example of actual use? The example you're adding to the docs doesn't quite do what it says in the description; it replaces all types not having value with void, instead of finding those that have value.
You need to check feature macros against their specified values (e.g. >= 2019xx), not just whether they are defined. (For a lambda to be usable as Expr the compiler also needs to support lambdas in unevaluated contexts, but I suppose the trait doesn't technically require that.)
Thanks for your feedback, @pdimov.
Sure, I'll update the example to more descriptive. The basic idea is just to enable C++20 style lambdas (especially with if constexpr and requires) for simplicity of usage (instead of declaring aliases).
Yeah, I was trying that but both clang and gcc didn't set the date correctly.
@pdimov Updated the example. Hopefully, the update makes it more clear/descriptive. I also check again whether feature macros can be used purely without any workarounds but it seems that they always return the same standard date although the implementation differs :/
- https://godbolt.org/z/Ga9zx4Gs8
@pdimov I updated feature macros to verify the date as you suggested. I hope that works for you. Is there anything else you would like me to address? Thank you.
It's fine; but I have more pressing things to do at the moment, so I'll need to come back to this later, and maybe not in time for 1.77.
No worries @pdimov , fully understood. Thank you. Pinging, just in case you are free and/or to show that the MR isn't stale.
Hey @pdimov. I know you are busy, just pinging in case you are available, no worries if not. Thanks.
I sat on this for a while because I wasn't sure what I want to do with it. Adding references doesn't feel like the right thing to do, for example.
But I've now made up my mind and I don't think it belongs in the library, it's not a good fit conceptually. Sorry.
It's still cool and would make a good blog post.