Skip to content

Commit a3eabbd

Browse files
committed
fixed param passing for action
1 parent 006aec8 commit a3eabbd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

include/fsm_cxx/fsm-sm.hh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,15 @@ namespace fsm_cxx {
279279
int> = 0>
280280
action_t(_Callable &&f, _Args &&...args) {
281281
using namespace std::placeholders;
282-
_f = fsm_cxx::util::cool::bind_tie<4>(std::forward<_Callable>(f), std::forward<_Args>(args)..., _1, _2, _3, _4);
282+
constexpr auto count = 4;
283+
_f = fsm_cxx::util::cool::bind_tie<count>(std::forward<_Callable>(f), std::forward<_Args>(args)..., _1, _2, _3, _4);
284+
}
285+
286+
template<typename _Callable, typename... _Args>
287+
void update(_Callable &&f, _Args &&...args) {
288+
using namespace std::placeholders;
289+
constexpr auto count = 4;
290+
_f = fsm_cxx::util::cool::bind_tie<count>(std::forward<_Callable>(f), std::forward<_Args>(args)..., _1, _2, _3, _4);
283291
}
284292

285293
/**
@@ -607,16 +615,18 @@ namespace fsm_cxx {
607615
to = to_;
608616
return (*this);
609617
}
610-
transition_builder &guard(Guard &&guard_) {
611-
guard_fn = guard_;
618+
transition_builder &guard(Guard &&fn) {
619+
guard_fn = std::move(fn);
612620
return (*this);
613621
}
614-
transition_builder &entry_action(Action &&fn) {
615-
entry_fn = fn;
622+
template<typename _Callable, typename... _Args>
623+
transition_builder &entry_action(_Callable &&f, _Args &&...args) {
624+
entry_fn.update(f, args...);
616625
return (*this);
617626
}
618-
transition_builder &exit_action(Action &&fn) {
619-
exit_fn = fn;
627+
template<typename _Callable, typename... _Args>
628+
transition_builder &exit_action(_Callable &&f, _Args &&...args) {
629+
exit_fn.update(f, args...);
620630
return (*this);
621631
}
622632
};

0 commit comments

Comments
 (0)