Skip to content

Make transition_sa and transition_sg constructors constexpr - #714

Merged
kris-jusiak merged 1 commit into
boost-ext:masterfrom
cierny:fix-sml-transition-sa-constexpr
Jul 12, 2026
Merged

Make transition_sa and transition_sg constructors constexpr#714
kris-jusiak merged 1 commit into
boost-ext:masterfrom
cierny:fix-sml-transition-sa-constexpr

Conversation

@cierny

@cierny cierny commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Every fully-formed transition<…> constructor is already constexpr, but the two anonymous-transition intermediates are not: transition_sa and transition_sg.

This meant a transition table containing such a row couldn't be built in a constant expression, blocking constinit / static initialization of an sm<> that uses one.

Both just forward to already-constexpr base constructors, so it's a one-word change per type with no behavioral or ABI impact. Includes a regression test in test/ft/constexpr.cpp that fails to compile without the fix.

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.
@kris-jusiak
kris-jusiak merged commit 326b948 into boost-ext:master Jul 12, 2026
6 checks passed
@kris-jusiak

Copy link
Copy Markdown
Collaborator

Thanks @cierny

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.

2 participants