Mahmoud Emam
Mahmoud Emam

Reputation: 1527

transition Vs custom_reaction in boost.statechart library

I've read the tutorial of boost.statechart library and its examples, and I've a question related to the transition and its action.

There are two ways to define the transition using transition<> and custom_reaction but what is the main difference between them and when to use anyone of this?

Upvotes: 2

Views: 402

Answers (1)

sehe
sehe

Reputation: 393934

Custom reactions are more versatile. However they're also more work and more error prone.

Refer back to this section in the docs where lists limitations and concludes:

All these limitations can be overcome with custom reactions. Warning: It is easy to abuse custom reactions up to the point of invoking undefined behavior. Please study the documentation before employing them!

So you use custom reactions when you know what you are doing and require the flexibility.

Upvotes: 1

Related Questions