Skip to content

History

Sergei Fedorov edited this page Nov 20, 2016 · 1 revision

By default all states and state machines get 'cleared' after exit. Technically the state objects are default-constructed and assigned to existing objects after next state has been entered. Move assignment will be used if applicable.

To avoid such behavior and store state between exit and enter a state should declare it has history. To do so, a tag ::afsm::tags::has_history should be used.

If a state has complex and costly construction and/or assignment, an exit action can be used to clear the state and the history tag can be used to prohibit the reconstruction of the state. It can improve performance with complex states.

struct my_state : state<my_state, ::afsm::tags::has_history> {
};
Clone this wiki locally