Question
I want to get the current states in action. I found some solutions in [#94] and tried to pass sm to my action function. But it didn't work for me.
My code
#include <iostream>
#include <cassert>
#include <boost/sml.hpp>
namespace sml = boost::sml;
struct e1 {};
struct e2 {};
class s1;
class s2;
class s3;
class s4;
auto action1 = [](const auto& e, auto& sm) {
sm.visit_current_states([](auto state) {
cout << "Current State:" << state.c_str() << endl;
}};
struct table {
auto operator()() const noexcept {
using namespace sml;
return make_transition_table(
*state<s1> + event<e1> / action1 = state<s3>
, state<s1> + event<e2> = state<s2>
, state<s3> + event<e2> = state<s4>
);
}
};
int main() {
using namespace sml;
sm<table> sm;
sm.process_event(e1{});
assert(sm.is(state<s4>));
}
Error
Some compile errors occured.
Specifications
- Version:BOOST_SML_VERSION 1'1'4
- Platform:msvc2019
Question
I want to get the current states in action. I found some solutions in [#94] and tried to pass sm to my action function. But it didn't work for me.
My code
Error
Some compile errors occured.
Specifications