From d3fa5b3d6e87cff4dc4230f449e8e1185c292024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Borz=C4=99cki?= Date: Mon, 29 Jun 2020 16:58:45 +0200 Subject: [PATCH 1/2] Added posibility to test current state in ortogonal state machines --- include/boost/sml.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/boost/sml.hpp b/include/boost/sml.hpp index 948b6083..7d3506aa 100644 --- a/include/boost/sml.hpp +++ b/include/boost/sml.hpp @@ -1703,6 +1703,20 @@ class sm { }); return result; } + template , class TState> + bool is_one_of_current_states_as(const TState&) const { + using type = typename T::type; + using sm_impl_t = sm_impl>; + 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([&](auto state) { + (void)state; + result |= (aux::get_id((states_ids_t *)0) == + aux::get_id((states_ids_t *)0)); + }); + return result; + } template , class... TStates, __BOOST_SML_REQUIRES(!aux::is_same::value && aux::always::value)> void set_current_states(const TStates &...) { From 2303acbaa88055acf80b6f47f1d150b2566a03ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Borz=C4=99cki?= Date: Tue, 30 Jun 2020 11:33:23 +0200 Subject: [PATCH 2/2] Improved possibility to test current state in orthogonal state machines --- include/boost/sml.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/sml.hpp b/include/boost/sml.hpp index 7d3506aa..cdec5f55 100644 --- a/include/boost/sml.hpp +++ b/include/boost/sml.hpp @@ -1712,8 +1712,11 @@ class sm { auto result = false; visit_current_states([&](auto state) { (void)state; - result |= (aux::get_id((states_ids_t *)0) == - aux::get_id((states_ids_t *)0)); + if ((aux::get_id((states_ids_t *)0) == + aux::get_id((states_ids_t *)0))) { + result = true; + return; + } }); return result; }