Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to check if one of orthogonal states is as expected #353

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,23 @@ class sm {
});
return result;
}
template <class T = aux::identity<sm_t>, class TState>
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like a nice utility 👍 I don't think is required to be part of the sml core, it can be just a free function in the examples or extensions instead as it's implemented using visit_current_states

bool is_one_of_current_states_as(const TState&) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

sml.hpp should not be changed directly as it's a generated file using tools/pph.sh

using type = typename T::type;
using sm_impl_t = sm_impl<typename TSM::template rebind<type>>;
using state_t = typename sm_impl_t::state_t;
using states_ids_t = typename sm_impl_t::states_ids_t;
auto result = false;
visit_current_states<T>([&](auto state) {
(void)state;
if ((aux::get_id<state_t, typename TState::type>((states_ids_t *)0) ==
aux::get_id<state_t, typename decltype(state)::type>((states_ids_t *)0))) {
result = true;
return;
}
});
return result;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tests to verify the behaviour will prevent breaking the functionality in the future ✅

template <class T = aux::identity<sm_t>, class... TStates,
__BOOST_SML_REQUIRES(!aux::is_same<no_policy, typename TSM::testing_policy>::value && aux::always<T>::value)>
void set_current_states(const TStates &...) {
Expand Down