Make transition_sa and transition_sg constructors constexpr - #714
Merged
kris-jusiak merged 1 commit intoJul 12, 2026
Merged
Conversation
Every fully-formed transition variant's constructor is already constexpr, but the two anonymous-transition intermediates built from a target state -- transition_sa (state + action) and transition_sg (state + guard) -- were missed. Without constexpr on these, a transition table containing such a row can't be built in a constant expression, so an sm<> whose table contains one can't be constinit / statically initialized. Both constructors have empty bodies that forward to already-constexpr base constructors, so this is a one-word change per type with no behavioral or ABI impact -- constexpr on a constructor is purely permissive. Add a regression test (test/ft/constexpr.cpp) that statically initializes an sm<> whose table contains both an anonymous guarded transition (transition_sg) and an anonymous action transition (transition_sa); it fails to compile without the fix.
Collaborator
|
Thanks @cierny |
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.
Every fully-formed
transition<…>constructor is alreadyconstexpr, but the two anonymous-transition intermediates are not:transition_saandtransition_sg.This meant a transition table containing such a row couldn't be built in a constant expression, blocking
constinit/ static initialization of ansm<>that uses one.Both just forward to already-
constexprbase constructors, so it's a one-word change per type with no behavioral or ABI impact. Includes a regression test intest/ft/constexpr.cppthat fails to compile without the fix.