Closed szaszm closed 1 year ago
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. Please indicate if you'd like to do (aspects of) these, otherwise I'll take care of them.
Initial remarks, things todo (irrespective of who will):
nsel_P2505R
, similar to nsel_P0323R
, see below.nsel_P2505R
.nsel_P2505R
Wrote "expected-lite uses 3 and higher" below based on a quick inspection, unsure if it is correct.
// Monadic operations proposal revisions:
//
// P2505R0: 0 (2021-12-12)
// P2505R1: 1 (2022-02-10)
// P2505R2: 2 (2022-04-15)
// P2505R3: 3 (2022-06-05) *
// P2505R4: 4 (2022-06-15)
// P2505R5: 5 (2022-09-20)
//
// expected-lite uses 3 and higher
#ifndef nsel_P2505R
# define nsel_P2505R 3
#endif
// ...
#if nsel_P2505R >= 3
// P2505 code
#endif
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 error_or
(a separate feature IMO), but it ended up closer to R3. I just noticed that I should've used remove_cv_t
behavior (instead of remove_cvref_t
equivalent) for transform
and transform_error
, I'll fix that.
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 error_or
implementation), but R3 can still be selected with the macro.
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 :) Thank you so much for this nice, substantial contribution!
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.