Skip to content

Make transitions<aux::true_type>::execute constexpr - #716

Merged
kris-jusiak merged 1 commit into
boost-ext:masterfrom
koralkulacoglu:constexpr-unexpected-event-execute
Aug 9, 2026
Merged

Make transitions<aux::true_type>::execute constexpr#716
kris-jusiak merged 1 commit into
boost-ext:masterfrom
koralkulacoglu:constexpr-unexpected-event-execute

Conversation

@koralkulacoglu

@koralkulacoglu koralkulacoglu commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Added constexpr to transitions<aux::true_type>::execute.

Also a regression test to test/ft/constexpr.cpp that fails to compile without the fix. Verified on clang and gcc at C++14/17/20.

Copilot AI lite review requested due to automatic review settings August 9, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>::execute as constexpr in include/boost/sml.hpp.
  • Add a regression test that constructs a constexpr sm<> containing an unexpected_event<> transition row.
  • Extend the constexpr FT test event set with e2 to 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
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
koralkulacoglu force-pushed the constexpr-unexpected-event-execute branch from f9a2f42 to 797c61d Compare August 9, 2026 00:49
@koralkulacoglu
koralkulacoglu marked this pull request as ready for review August 9, 2026 00:56
@kris-jusiak
kris-jusiak merged commit 2074a7e into boost-ext:master Aug 9, 2026
6 checks passed
@kris-jusiak

Copy link
Copy Markdown
Collaborator

Thanks @koralkulacoglu

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.

3 participants