Skip to content

Commit

Permalink
Fix #25: Fix ambiguities with overloaded std::forward definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkem committed Oct 29, 2020
1 parent 4052562 commit d29ff65
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ namespace fsmlite {

template<class F, class Arg1, class Arg2>
invoke_as_binary_fn_result_t<F, Arg1, Arg2>invoke_as_binary_fn(F&& f, Arg1&& a, Arg2&& b) {
return binary_fn_helper<F, Arg1, Arg2>::invoke(forward<F>(f), forward<Arg1>(a), forward<Arg2>(b));
return binary_fn_helper<F, Arg1, Arg2>::invoke(
detail::forward<F>(f),
detail::forward<Arg1>(a),
detail::forward<Arg2>(b));
}

// basic template metaprogramming stuff; note that we could
Expand Down
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test_player
test_recursive
test_row
test_scoped
test_shared
test_traits
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ check_PROGRAMS = \
test_recursive \
test_row \
test_scoped \
test_shared \
test_traits

TESTS = $(check_PROGRAMS)
33 changes: 33 additions & 0 deletions tests/test_shared.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <cassert>
#include <memory>

#include "fsm.h"

class state_machine: public fsmlite::fsm<state_machine> {
friend class fsm; // base class needs access to transition_table
public:
enum states { Init, Exit };

using event = std::shared_ptr<int>;

void action(const event&) { }

private:
using m = state_machine;

using transition_table = table<
// Row-Type Start Event Target Action
// -----------+-----+------+------+----------+-
mem_fn_row< Init, event, Exit, &m::action >
// -----------+-----+------+------+----------+-
>;
};

int main()
{
state_machine m;
assert(m.current_state() == state_machine::Init);
m.process_event(state_machine::event());
assert(m.current_state() == state_machine::Exit);
return 0;
}

0 comments on commit d29ff65

Please sign in to comment.