docs: document on_entry<_> multi-TU limitation and dispatch priority (#565)#703
Merged
kris-jusiak merged 5 commits intoMay 29, 2026
Conversation
…(issue boost-ext#565) on_entry<_> instantiates its action for every event that can reach the state — including back::initial and back::anonymous — because it maps to a generic on_entry<_, _> handler. When the action has a generic (auto/template) call operator, each event type generates a distinct template specialisation. Placing only a declaration in a header and defining the body in a separate .cpp leaves the `initial`-event specialisation undefined → linker error. Add a comment above the on_entry struct in sml.hpp explaining this, the two workarounds (define inline; or use on_entry<E> with a specific event type), and the dispatch priority rule (specific handler wins; wildcard is fallback for events without a specific handler). Add test `on_entry_wildcard_fires_for_all_events` to test/ft/states.cpp verifying: - on_entry<e1> fires when entering via e1 (specific handler takes priority; wildcard does NOT fire) - on_entry<_> fires when entering via e2 (no specific handler → wildcard fires)
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.
Summary
Closes #565 (documentation fix — no library behaviour change).
What was happening
on_entry<_>maps to a genericon_entry<_, _>handler that is instantiated for every event that can reach the state, including the internalback::initialandback::anonymousevents. When the action has a generic (auto/template) call operator, each event type generates a distinct template specialisation. Placing only a declaration in a header and defining the body in a separate.cppleaves theinitial-event specialisation with no definition → linker error even though the code looks correct.Changes
include/boost/sml.hpp— comment block added above theon_entrystruct:initialspecialisation)on_entry<E>with a specific type, or use a non-generic call operatortest/ft/states.cpp— new teston_entry_wildcard_fires_for_all_events:s3state at file scope (needed by the test)on_entry<_>andon_entry<e1>are registered for the same state, the specific handler fires fore1and the wildcard is the fallback for events without a specific handler (heree2)Verified
cl.exe /W4 /WX)