-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add monadic operations (P2505) #60
Conversation
- implement std::invoke as detail::invoke - add the monadic functions from P2505 - write some tests
I accidentally discovered that by declaring a templated data member pointer type, the type can be deduced to a function type, resulting in a member function pointer type. This was I could deduce cv-qualifiers and noexcept-ness all in one, without having to resort to more metaprogramming or writing 8x overloads. Removed parens and added SFINAE checks to clarify that the parameter is a member pointer type, and the member type gets deduced to a function type, resulting in a member function pointer.
Oh, wow, thank you very much for all this work! Also thanks for trying and follow my idiosyncratic code layout :) Wrote some remarks below I could come up with now. Initial remarks, things todo (irrespective of who will):
nsel_P2505R Wrote "expected-lite uses 3 and higher" below based on a quick inspection, unsure if it is correct.
|
I can have a look at these later this week. I'm happy that my contribution is appreciated. My intention was to implement the C++23 draft version, which is P2505R5, except for I'm planning to finish this, including the docs and feature selection macro, but if you do it before me, that's also fine by me. If you want to work on this feature before I do, you have full commit/write access to the pull request source branch on my fork. |
Appreciate it if you could do (most of) it. Chances are you'll be quicker than I'll be :) |
Added the config macro, updated to R5 by default (including an In the README, I updated the "Interface of expected" section, not the "Algorithms for expected", because these are only member functions in the interface section, while there were only free standing functions in the Algorithms section, and the additions are all member functions. Let me know if this looks good, or there are any more changes needed. |
Looks great to me :) |
std::invoke
asdetail::invoke
and_then
,or_else
,transform
andtransform_error
(both normal andexpected<void>
)error_or
P2505R3 proposal: https://wg21.link/P2505R3
P2505R5 proposal: https://wg21.link/P2505R5
I tested with GCC 13.2, Clang 16, and with the GitHub Actions CI job. Tried my best to follow the formatting conventions, but might have missed a few spots.
Related to #56
Let me know if any changes are necessary. I realize that this is a large diff to review at once. I can split it up to multiple parts if necessary.