Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,8 @@ struct get_event_mapping_impl_helper<on_entry<T1, T2>, TMappings>
template <class T1, class T2, class TMappings>
struct get_event_mapping_impl_helper<on_exit<T1, T2>, TMappings>
: decltype(get_event_mapping_impl<on_exit<T1, T2>>((TMappings *)0)) {};
template <class TMappings>
struct get_event_mapping_impl_helper<anonymous, TMappings> : decltype(get_event_mapping_impl<anonymous>((TMappings *)0)) {};
template <class T, class TMappings>
using get_event_mapping_t = get_event_mapping_impl_helper<T, TMappings>;
} // namespace back
Expand Down
3 changes: 3 additions & 0 deletions test/ft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ add_test(test_fwd test_fwd)
add_executable(test_history history.cpp)
add_test(test_history test_history)

add_executable(test_issue_171 issue_171.cpp)
add_test(test_issue_171 test_issue_171)

add_executable(test_issue_253 issue_253.cpp)
add_test(test_issue_253 test_issue_253)

Expand Down
44 changes: 44 additions & 0 deletions test/ft/issue_171.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// 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>

namespace sml = boost::sml;

test issue_171_event_any_is_not_fired_twice = [] {
struct e1 {};

struct issue_171_counters {
int init_calls = 0;
int wildcard_calls = 0;
};

struct issue_171_transitions {
auto operator()() const noexcept {
using namespace sml;
const auto issue_171_idle = sml::state<class issue_171_idle>;
const auto issue_171_s1 = sml::state<class issue_171_s1>;
const auto issue_171_s2 = sml::state<class issue_171_s2>;

// clang-format off
return make_transition_table(
*issue_171_idle / [](issue_171_counters& counters) { ++counters.init_calls; } = issue_171_s1
, issue_171_s1 + event<_> / [](issue_171_counters& counters) { ++counters.wildcard_calls; }
, issue_171_s2 + event<e1> / [] {}
);
// clang-format on
}
};

issue_171_counters counters{};
sml::sm<issue_171_transitions> sm{counters};

sm.process_event(e1{});

expect(1 == counters.init_calls);
expect(1 == counters.wildcard_calls);
};
Loading