Make transitions<aux::true_type>::execute constexpr - #716
Merged
kris-jusiak merged 1 commit intoAug 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes a previously started “constexpr sweep” by making the transitions<aux::true_type>::execute fallback constexpr, enabling state machines that include unexpected_event<> rows to be statically initialized (e.g., constexpr sml::sm<...> sm{};) without failing constant-expression rules.
Changes:
- Mark
transitions<aux::true_type>::executeasconstexprininclude/boost/sml.hpp. - Add a regression test that constructs a constexpr
sm<>containing anunexpected_event<>transition row. - Extend the constexpr FT test event set with
e2to drive the new unexpected-event scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/boost/sml.hpp | Makes the unexpected-event fallback transition executor constexpr to allow constexpr/static initialization paths. |
| test/ft/constexpr.cpp | Adds a compile-time regression test covering unexpected_event<> in a constexpr-constructed state machine. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
koralkulacoglu
marked this pull request as draft
August 9, 2026 00:47
The constexpr sweep in 1df1c1a marked every sibling in this family constexpr -- transitions<T, Ts...>, transitions<T> and transitions<aux::false_type> -- but missed transitions<aux::true_type>. There was no technical blocker at the time: the callee process_internal_event was already constexpr in that same commit, and no test constructed such a machine in a constant expression, so nothing caught it. This specialization is the unexpected-event fallback, and it is reached during start() via on_entry<_, initial>, so a state machine containing an unexpected_event<> row could not be statically initialized at all -- even without processing a single event. constexpr on a function template is purely permissive, so there is no behavioral or ABI impact. Add a regression test to test/ft/constexpr.cpp; it fails to compile without the fix on both clang and gcc. Co-authored-by: Cursor <cursoragent@cursor.com>
koralkulacoglu
force-pushed
the
constexpr-unexpected-event-execute
branch
from
August 9, 2026 00:49
f9a2f42 to
797c61d
Compare
koralkulacoglu
marked this pull request as ready for review
August 9, 2026 00:56
Collaborator
|
Thanks @koralkulacoglu |
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.
Added
constexprtotransitions<aux::true_type>::execute.Also a regression test to
test/ft/constexpr.cppthat fails to compile without the fix. Verified on clang and gcc at C++14/17/20.