-
Notifications
You must be signed in to change notification settings - Fork 179
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1703,6 +1703,23 @@ class sm { | |
}); | ||
return result; | ||
} | ||
template <class T = aux::identity<sm_t>, class TState> | ||
bool is_one_of_current_states_as(const TState&) const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 &...) { | ||
|
There was a problem hiding this comment.
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