는 여기 전환 테이블로 std::tr1::tuple
를 사용하는 일반적인 상태 머신의 독자적인 구현이 있습니다런타임시 boost :: fusion :: vector에서 요소를 찾는 방법은 무엇입니까?
template<State StartState, Event TriggerEvent, State TargetState>
struct transition {...};
typedef std::tr1::tuple< transition< ready , run , running >
, transition< running , terminate, terminating >
, transition< terminating, finish , terminated >
> transition_table;
기능
template<typename Transitions>
State find_next_state(State current
, Event event
, const Transitions& transition_table);
주어진 전환 테이블의 다음 상태를 찾을 수에게있다 현재 상태 및 이벤트.
이 플랫폼의 tuple
구현이 10 개를 초과하는 경우를 제외하고는 모두 잘 작동합니다. 동일한 것은 boost::tuple
에 해당하는 것 같습니다. 따라서 boost::fusion::vector
을 대신 사용하려고합니다. 하지만 fusion's find_if
은 "단항 MPL Lambda Expression"만 사용합니다. 컴파일 타임에만 작동합니다.
위 주어진대로 find_next_state()
을 어떻게 구현할 수 있습니까?
참고 : GCC 4.1.2을 공급, 우리는 C++ 03 + TR1 붙어있어
이 독점 임베디드 플랫폼.
대안 작업량으로 튜플을 튜플에 압축 할 수 있습니까? – Angew
런타임에서 융합 시퀀스와 함수로 작동하는 자신 만의'find_if'를 작성하는 것은 어떻습니까? – ForEveR
왜 처음에'튜플 (tuple) '을 사용합니까? '이행 '은 어떤 상태가 있습니까? 그렇지 않으면'mpl :: vector'와'mpl :: for_each'를 사용하여 런타임에 반복 할 수 있습니다. – Abyx