Skip to content

AK: Variant thing - forwarding [3/N] - #26547

Draft
Hendiadyoin1 wants to merge 7 commits into
SerenityOS:masterfrom
Hendiadyoin1:c++26-cleanup
Draft

AK: Variant thing - forwarding [3/N]#26547
Hendiadyoin1 wants to merge 7 commits into
SerenityOS:masterfrom
Hendiadyoin1:c++26-cleanup

Conversation

@Hendiadyoin1

Copy link
Copy Markdown
Contributor

While c++26 was not required for most of these, it did make it a bit easier at some points

This consists of 2 main parts:

  1. Getting the Variant constructor in a more canonical form,
    This is step 1 of getting constexpr working for it, and makes some more ugly parts of it disappear
  2. Cleaning up some redundant parts around visit

CC: @alimpfard as our local template and variant expert

@github-actions github-actions Bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Jan 11, 2026
Comment thread AK/Variant.h Outdated
Comment thread AK/Variant.h Outdated
@Hendiadyoin1

Copy link
Copy Markdown
Contributor Author

Whoops pack indexing only works in gcc-15+ which ubuntu doesnt ship for 22.04, so it's off limits

@Hendiadyoin1
Hendiadyoin1 force-pushed the c++26-cleanup branch 2 times, most recently from d32d9bc to 9ede9e3 Compare January 11, 2026 16:25
@nico

nico commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

Happy to have @alimpfard review this, but in case he's busy: From a distance, commit 3 looks nice and the tests in commit 2 are nice, but commit 2 is about the same amount of code lhs and rhs, so it feels a bit like a sideways change.

@alimpfard alimpfard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Largely LGTM, and I really like that the hacky constructors are gone (yay)

Comment thread AK/Variant.h Outdated
Comment thread AK/Variant.h Outdated
Comment thread AK/Variant.h Outdated
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions

github-actions Bot commented Mar 8, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Mar 8, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

Comment thread AK/Variant.h
Comment thread AK/Variant.h
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Apr 7, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

@github-actions github-actions Bot closed this Apr 14, 2026
@Hendiadyoin1 Hendiadyoin1 reopened this Apr 24, 2026
@github-actions github-actions Bot removed the stale label Apr 25, 2026
@Hendiadyoin1
Hendiadyoin1 force-pushed the c++26-cleanup branch 4 times, most recently from e124f21 to 8a5828f Compare May 4, 2026 12:37
@Hendiadyoin1
Hendiadyoin1 marked this pull request as ready for review July 4, 2026 13:31
@github-actions github-actions Bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 4, 2026
@Hendiadyoin1 Hendiadyoin1 removed the stale label Jul 4, 2026
@Hendiadyoin1
Hendiadyoin1 requested a review from alimpfard July 4, 2026 13:52
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Jul 26, 2026
@Hendiadyoin1
Hendiadyoin1 marked this pull request as draft July 31, 2026 22:33
@Hendiadyoin1

Copy link
Copy Markdown
Contributor Author

Moved parts of it to #26914, to get some parts in faster

@github-actions github-actions Bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 31, 2026
@Hendiadyoin1 Hendiadyoin1 changed the title AK: Some Variant cleanup after c++26 AK: Variant thing - forwarding [3/N] Aug 1, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 23, 2026
@Hendiadyoin1 Hendiadyoin1 added ⛔️ pr-is-blocked PR is blocked by something outside of the author's control, protected from stalebot and removed stale labels Aug 24, 2026
This makes the overload logic a lot cleaner, as well as removing the
concept of valid but unreachable variant states.
Also this likely reduces some symbol sizes in LibSoftGPU, which to my
knowledge was the only user of this feature.

As a Side-effect the AK::Variant is now a type alias, so traits need to
check against the `Detail` version.
For constructing the Storage  we use a sentinel value (`VariantIndex`)
to pass along the desired depth/type into the constructor chain.
This is done as we cant easily start the lifetime of the alternatives
after the union was instantiated.
Upcoming c++26 features should fix this
(see trivial unions (P3074R7) and std::start_lifetime (P3726R2))
For move and copy assignment we destroy the active member, and then
replace the whole storage, trivial unions may also make this nicer.

Also Overload resolution now returns the chosen overload wrapper, which
now also holds the index of that overload, which avoids re-walking the
type list to get the index.
@github-actions github-actions Bot removed the ⛔️ pr-is-blocked PR is blocked by something outside of the author's control, protected from stalebot label Aug 28, 2026
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.

4 participants