Skip to content

Replace nested promote/lift switches with std::variant dispatch#64

Open
d-torrance wants to merge 1 commit into
MichaelABurr:aringsfrom
d-torrance:promote-lift
Open

Replace nested promote/lift switches with std::variant dispatch#64
d-torrance wants to merge 1 commit into
MichaelABurr:aringsfrom
d-torrance:promote-lift

Conversation

@d-torrance

Copy link
Copy Markdown
Collaborator

Split off from #62

Replaces the ~130-line nested switch in ConcreteRing::promote and the ~100-line nested switch in ConcreteRing::lift with a RingVariant + toVariant helper and a two-argument std::visit lambda that calls mypromote/mylift directly on the unwrapped concrete ring references.

The old lift switch had three latent bugs now fixed automatically:

  • ring_RRi and ring_CCi source arms were missing (those mylift specializations in aring-translate.hpp were unreachable)
  • The ring_CC→ring_CCC and ring_CCC→ring_CC lift template args were swapped

Structural drift is now impossible: adding a new ring type requires only adding it to RingVariant and toVariant; the compiler enforces coverage.

Cc: @haackett

Replaces the ~130-line nested switch in ConcreteRing::promote and the
~100-line nested switch in ConcreteRing::lift with a RingVariant +
toVariant helper and a two-argument std::visit lambda that calls
mypromote/mylift directly on the unwrapped concrete ring references.

The old lift switch had three latent bugs now fixed automatically:
- ring_RRi and ring_CCi source arms were missing (those mylift
  specializations in aring-translate.hpp were unreachable)
- The ring_CC→ring_CCC and ring_CCC→ring_CC lift template args
  were swapped

Structural drift is now impossible: adding a new ring type requires only
adding it to RingVariant and toVariant; the compiler enforces coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant