c++ - There seems to be a harsh limit in templates...
This transition table for a BACnet 'receive frame' state machine, using boost's state machine, won't compile: Right about in the middle of it, the compiler says it expects ">"... typedef mpl::list < transition< s_idle, e_eatoctet, s_idle, &rec_frm_sm::do_naught > , transition< s_idle, e_preamble1, s_preamble, &rec_frm_sm::do_naught > , transition< s_preamble, e_preamble1, s_preamble, &rec_frm_sm::do_ignore > , transition< s_preamble, e_notpreamb, s_idle, &rec_frm_sm::do_reset > , transition< s_preamble, e_preamble2, s_header, &rec_frm_sm::do_naught > , transition< s_header, e_frametype, s_header, &rec_frm_sm::do_savfrmt > , transition< s_header, e_dest, s_header, &rec_frm_sm::do_savdest > , transition< s_header, e_source, s_header, &rec_frm_sm::do_savsrc > , transition< s_header, e_length1, s_header, &rec_frm_sm::do_savlen1 > , transition< s_header, e_length2, s_header, &rec_frm_sm::do_savlen2 > , transition< s_header, e_headCRC, s_headCRC, &rec_frm_sm::do_vrfhdr > , transition< s_headCRC, e_badhCRC, s_idle, &rec_frm_sm::do_reset > , transition< s_headCRC, e_frm2long, s_idle, &rec_frm_sm::do_reset > , transition< s_headCRC, e_no_data, s_idle, &rec_frm_sm::do_reset > , transition< s_headCRC, e_notforus, s_idle, &rec_frm_sm::do_naught > , transition< s_headCRC, e_data, s_data, &rec_frm_sm::do_savdat1 > , transition< s_data, e_data, s_data, &rec_frm_sm::do_savdata > , transition< s_data, e_dataCRC1, s_data, &rec_frm_sm::do_naught > , transition< s_data, e_dataCRC2, s_dataCRC, &rec_frm_sm::do_vrfdCRC > , transition< s_dataCRC, e_baddCRC, s_idle, &rec_frm_sm::do_reset > , transition< s_dataCRC, e_goodCRC, s_idle, &rec_frm_sm::do_rcvfrm >::type transition_table;Actually, it doesn't seem to be a length limit; I've just abbreviated a lot of the names... typedef mpl::list < transition< idl, e_eatoct, idl, &rf::naught > , transition< idl, e_pream1, pream, &rf::naught > , transition< pream, e_pream1, pream, &rf::ignore > , transition< pream, e_nopream, idl, &rf::reset > , transition< pream, e_pream2, hd, &rf::naught > , transition< hd, e_frmtype, hd, &rf::savfrmt > , transition< hd, e_dst, hd, &rf::savdst > , transition< hd, e_src, hd, &rf::savsrc > , transition< hd, e_len1, hd, &rf::savlen1 > , transition< hd, e_len2, hd, &rf::savlen2 > /* , transition< hd, e_hd_CRC, hd_CRC, &rf::vrfhdr > , transition< hd_CRC, e_badhCRC, idl, &rf::reset > , transition< hd_CRC, e_frm2lng, idl, &rf::reset > , transition< hd_CRC, e_no_dat, idl, &rf::reset > , transition< hd_CRC, e_noforus, idl, &rf::naught > , transition< hd_CRC, e_dat, dat, &rf::savdat1 > , transition< dat, e_dat, dat, &rf::savdat > , transition< dat, e_datCRC1, dat, &rf::naught > , transition< dat, e_datCRC2, datCRC, &rf::vrfdCRC > , transition< datCRC, e_baddCRC, idl, &rf::reset > , transition< datCRC, e_okCRC, idl, &rf::rcvfrm > */::type transition_table;..and yet the problem happens always in the same line. When the overflow section is commented out like above, the program compiles. Would this be a limit on template depth, or number of params? dan
Dec 12 2003
Never mind, it's a boost artificial limit of 10 on list. For whoever else may be concerned, the solution is to, instead of #include "boost/mpl/list/list.hpp" typedef mpl::list < ...only up to 10 items... > to, #include "boost/mpl/list/list30.hpp" typedef mpl::list22 < ...22 items... > --i.e.: listXX where XX is the exact number of items. Cheers! dan
Dec 12 2003