-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy patheval.cpp
More file actions
39 lines (33 loc) · 826 Bytes
/
eval.cpp
File metadata and controls
39 lines (33 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Copyright (c) 2016-2020 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/sml.hpp>
#include <cassert>
namespace sml = boost::sml;
namespace {
struct e1 {};
struct eval {
auto operator()() const {
const auto guard = [] { return true; };
const auto action = [](int &a) { ++a; };
// clang-format off
using namespace sml;
using sml::eval;
return make_transition_table(
*"idle"_s + event<e1> [ guard ] / (action, eval [ guard ] / action, action) = X
);
// clang-format on
}
};
} // namespace
int main() {
int a{};
sml::sm<eval> sm{a};
sm.process_event(e1{});
assert(3 == a);
assert(sm.is(sml::X));
}