Add the apply family to optional and expected, with trailing arguments throughout - #343
Merged
Merged
Conversation
Assisted-by: Claude:claude-fable-5
Assisted-by: Claude:claude-fable-5
Assisted-by: Claude:claude-fable-5
Assisted-by: Claude:claude-fable-5
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
🤖 Augment PR SummarySummary: This PR introduces the full Changes:
Technical Notes: Introduces MSVC-friendly tuple-like probing (avoiding eager 🤖 Was this summary useful? React with 👍 or 👎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Two deliveries in four commits, the second building directly on the first.
optionalandexpectedgain theapplyfamily (#339)apply,apply_r,apply_typeandapply_type_reliminate both states through one callable — the lower-level tool beside the monadic members, as onsumandchoice(#268). Both arms are required outright and must agree on one result type (apply_rconverts). The untaggedapplyhands each state's content over exactly asfn::applywould — apackor tuple-like payload by elements, asumpayload by dispatch, anything else (including achoice, a nominal boundary) whole — and the empty arm ofoptionalis invoked without a value.apply_typekeys each arm by the constructor tag that names the state —std::in_placefor the held value,std::nulloptfor empty,fn::unexpectfor the error — so the dispatch is airtight by construction even whereTandEinterconvert: a lonedoublearm silently serves both rows ofexpected<double, int>on the untagged path, while the tags never convert. As onsum::apply_type, a tuple-like payload's elements form is the tagged row's one signature (no pass-whole fallback; the untagged path keeps it), and within asumpayload the dispatch stays the value path — the tag guards the state, not the sum's rows.The engine route makes the composition automatic: both arms eliminate through the same machinery
fn::applyuses (probe==deed via the_is_applicablefamilies and the new_apply_taggeddispatchers), and the empty/void arms receive their tag as a prvalue, the exact shape the traits ask about.Trailing arguments become uniform across the family (#342)
sum::apply/apply_ralways accepted trailing arguments — the member leg offn::apply's engine protocol. Nothing ever forced that shape ontoapply_type/apply_type_r(no free-function counterpart) or ontochoice(an atom the freeapplynever dispatches), while the internal type-indexed machinery anticipated the arguments all along. Rectified additively:apply_type/apply_type_ron all four types, andchoice'sapply/apply_r, now take trailing arguments appended after each arm's unpacked content; the type-indexed trait families and union walkers thread them exactly as their value-path twins do.One MSVC portability lesson is baked into the implementation: a constrained-out declaration must not name
tuple_sizeraw (MSVC substitutes eagerly where gcc/clang stop at the failed constraint), so the tuple-like arms specify themselves through_elems_traits/_elems_traits_r, gated in the shape ofpfn's_apply_traits.Verified on gcc and clang across Debug/Release and both
VALIDATE_CXX23lanes, and on MSVC (build and ctest) at each delivery point.Closes #339
Closes #342
🤖 Generated with Claude Code