Skip to content

fix: value-initialize a missing reference dep (#718) - #729

Merged
kris-jusiak merged 7 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-718-expected-first-member
Oct 17, 2026
Merged

kris-jusiak merged 7 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-718-expected-first-member

Conversation

@PavelGuzenfeld

Copy link
Copy Markdown
Contributor

With BOOST_SML_CREATE_DEFAULT_CONSTRUCTIBLE_DEPS a missing T& dep was built as value_{missing_ctor_parameter<T>}. For an aggregate T that initializes the first member from the placeholder, which is ambiguous when the member has a greedy converting ctor like std::expected. Added a ctor overload for missing_ctor_parameter that value-initializes the backing store. Paren-init would also fix #718 but breaks missing vector/string deps.

Behaviour change: a missing std::vector<int>& dep used to hold {0} and std::string& one \0, now both are empty. Pinned in the test.

Test covers a C++14 greedy-ctor member (runs in CI) and std::expected where the library has it. gcc14/15, clang18/21 C++14 through 23, MSVC c++14/20/latest.

Closes #718

Comment thread include/boost/sml.hpp Outdated
struct pool_type_impl<T &, aux::enable_if_t<aux::is_constructible<T>::value && aux::is_constructible<T, const T &>::value>>
: pool_type_base {
constexpr explicit pool_type_impl(T &val) : value{val} {} // bind ref directly
constexpr explicit pool_type_impl(missing_ctor_parameter<T>) : value_{}, value{value_} {}// default-construct backing store

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
constexpr explicit pool_type_impl(missing_ctor_parameter<T>) : value_{}, value{value_} {}// default-construct backing store
constexpr explicit pool_type_impl(missing_ctor_parameter<T>) : value_{}, value{value_} {} // default-construct backing store

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Brace-init from missing_ctor_parameter aggregate-initialized T's first member, ambiguous when that member has a greedy converting ctor like std::expected. A missing vector/string dep is now empty instead of holding one element.
@PavelGuzenfeld
PavelGuzenfeld force-pushed the fix/issue-718-expected-first-member branch from 7633853 to 7ec73a0 Compare October 14, 2026 12:21
@kris-jusiak
kris-jusiak merged commit bc13fcb into boost-ext:master Oct 17, 2026
7 checks passed
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.

Compile error with std::expected as per state data

3 participants