I have to admit that I'm rather new to C++ and Boost Statecharts. I played around a little bit with the Statechart library and wanted to construct some "bigger" statemachines.
I give a very simple example of my problem. Lets assume a statemachine with only one state and a lot of self-transitions. How to construct something like that? Everything above of 20 transitions is rejected by the gcc(4.5.2) compiler ("wrong number of template arguments (21, should be 20)")
Here is some sample code:
#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>
#include <iostream>
#include <boost/mpl/list.hpp>
namespace sc = boost::statechart;
struct MyEvent1: sc::event<MyEvent1> {};
struct MyEvent2: sc::event<MyEvent2> {};
//...
struct MyEvent21: sc::event<MyEvent21> {};
struct MyState;
struct Statemachine: sc::state_machine<Statemachine, MyState> {};
struct MyState: sc::simple_state<MyState, Statemachine> {
typedef boost::mpl::list<
sc::transition< MyEvent1, MyState > ,
sc::transition< MyEvent2, MyState > ,
//...
sc::transition< MyEvent21 >
> reactions;
};
int main() {
//..
return 0;
}
Your problem is not actually related to Boost.Statechart, but rather to Boost.MPL, whose typelists you're making use of. From the Boost.MPL docs:
BOOST_MPL_LIMIT_LIST_SIZE
is an overridable configuration macro regulating the maximum arity of thelist
's andlist_c
's variadic forms. In this implementation of the library,BOOST_MPL_LIMIT_LIST_SIZE
has a default value of 20.
It continues:
To override the default limit, define
BOOST_MPL_LIMIT_LIST_SIZE
to the desired maximum arity rounded up to the nearest multiple of ten before including any library header.
So presumably you'll want the following before any #include
s:
#define BOOST_MPL_LIMIT_LIST_SIZE 30