Skip to content

fix: add sml::deps<Ts...> policy for explicit pool deps (issue #437)#690

Merged
kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-437-explicit-deps
May 28, 2026
Merged

fix: add sml::deps<Ts...> policy for explicit pool deps (issue #437)#690
kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-437-explicit-deps

Conversation

@PavelGuzenfeld
Copy link
Copy Markdown
Contributor

@PavelGuzenfeld PavelGuzenfeld commented May 27, 2026

Problem

When all actions and guards use generic 4-arg lambdas to access deps manually:

auto action = [](auto /*e*/, auto& /*sm*/, auto& deps, auto& /*states*/) {
    sml::aux::get<MyDep&>(deps).value = 99;
};

MyDep never appears in any explicitly-typed parameter list, so dep_list (computed via get_deps_targs_t) is empty. The pool deps_t never includes MyDep, and the static_cast from the user-provided pool to pool_type<MyDep&> fails to compile:

error: static_cast from 'aux::pool<>' to 'aux::pool_type<MyDep&>' is not valid

Closes #437.

Fix

Introduce sml::deps<Ts...> as a new SM policy that widens the deps pool to include explicitly named types:

MyDep dep;
sml::sm<MyTable, sml::deps<MyDep>> sm{dep};

Implementation

  1. back::policies::explicit_deps<Ts...> — new policy struct, follows same aux::pair<Tag__, Self> pattern as logger, thread_safe, etc.
  2. sm_policy::explicit_deps_policy — picked up via the existing get_policy mechanism.
  3. get_explicit_deps<P> helper — converts explicit_deps<Ts...>type_list<Ts&...> (with same const T&T& normalization as ignore::non_events); no_policy → empty list.
  4. sm::deps_t — joins explicit_dep_list before the auto-deduced dep_list; unique_t deduplicates when both list the same dep.
  5. Public aliastemplate<class... Ts> using deps = back::policies::explicit_deps<Ts...>;

The design is purely additive: existing SMs without the policy are unchanged.

Verified

  • GCC 14 C++17: 29/29 ft ✅
  • GCC 14 C++20: 29/29 ft ✅
  • MSVC 19.51 C++20: 34/34 ✅

Companion test PR: #691

@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch from 9cdfd4d to 8c300bb Compare May 27, 2026 11:45
@PavelGuzenfeld PavelGuzenfeld changed the title fix: add sml::deps<Ts...> policy for explicit pool dependencies (issue #437) fix: add sml::deps<Ts...> policy for explicit pool deps (issue #437) May 27, 2026
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch 2 times, most recently from b2ee4b6 to a5ed9ca Compare May 27, 2026 12:05
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch from cc95cff to 737253b Compare May 27, 2026 13:08
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch from 737253b to c89ce10 Compare May 27, 2026 13:10
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch from c89ce10 to 47698ee Compare May 27, 2026 13:14
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
…ext#437)

When all actions/guards use generic 4-arg lambdas with sml::aux::get<Dep&>(deps)
the dep type never appears in the auto-deduced dep_list, so pool<> never contains
Dep and the static_cast from pool<> → pool_type<Dep&> fails to compile.

Fix: introduce sml::deps<Ts...> SM policy that widens the pool to include explicitly
named types regardless of whether any action/guard signature names them.

Implementation:
- back::policies::explicit_deps<Ts...> : aux::pair<explicit_deps_policy__, ...>
- sm_policy::explicit_deps_policy picks it up via the existing get_policy mechanism
- get_explicit_deps<P> helper converts the policy to type_list<Ts&...> with
  const-normalization (const T& → T&, same as ignore::non_events)
- sm::deps_t joins explicit_dep_list ahead of the auto-deduced dep_list (unique_t
  deduplicates when both list a dep)
- Public alias: template<class... Ts> using deps = back::policies::explicit_deps<Ts...>

Usage:
  sml::sm<MyTable, sml::deps<MyDep>> sm{dep};

Verified: GCC C++17/C++20 (29/29 ft), MSVC C++20 (34/34)
Companion test: see PR boost-ext#691
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-437-explicit-deps branch from 3dabcee to 76013e2 Compare May 27, 2026 13:43
PavelGuzenfeld added a commit to PavelGuzenfeld/sml that referenced this pull request May 27, 2026
…t-ext#437)

Covers the two scenarios from issue boost-ext#437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR boost-ext#690).
@kris-jusiak kris-jusiak merged commit 60278cb into boost-ext:master May 28, 2026
5 checks passed
kris-jusiak pushed a commit that referenced this pull request May 28, 2026
Covers the two scenarios from issue #437:
- Single dep accessed only via generic 4-arg lambda (sml::aux::get<Dep&>(deps))
- Multiple explicit deps, both accessed via generic lambdas

Requires companion fix in sml.hpp (see PR #690).
@PavelGuzenfeld PavelGuzenfeld deleted the fix/issue-437-explicit-deps branch May 28, 2026 05:48
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.

pool<...> not initialized with passed dependency

2 participants