boost MPL::vector 未识别且元状态机 (MSM) 转换 table 未定义

boost MPL::vector not recognized and Meta State Machine (MSM) transition table not defined

我正在尝试学习 boost 的元状态机 (MSM) 库。

按照http://redboltz.wikidot.com/simple-state-machine中的简单状态机示例,我遇到了一些问题:

  1. 我在使用 boost::mpl::vector.

    定义状态机的 "transition table" 时遇到问题
    // Transition table
    struct transition_table:mpl::vector<
        //          Start   Event   Next    Action      Guard
        msmf::Row < State1, Event1, End,    msmf::none, msmf::none >
    > {};
    
  2. Qt Creator IDE 不检测并自动完成 mpl::vector(它只识别编号版本,即 mpl::vector0/1...)!!!

  3. 代码编译(没有错误)但是当我 运行 它时它崩溃了(在 state_machine_def.hpp 的第 203 行,这是关于 FSM 的转换处理程序)

  4. 我在 Windows 7 上使用 Boost 1.66 和 Qt 5.9.0 MinGW 32 位编译器。

  5. 我已将 boost 的路径添加到我的包含路径(因为 MSM 和 MPL header 只有库)

问题

Q1 - Why does not my system recognize the boost::mpl::vector?

Q2 - Replacing mpl::vector with mpl::vector1 (which is recognized by my IDE, QtCreator) does not solve my problem (run time crash)

温馨提示:上例中的SM只有一个转换入口。

非常感谢任何帮助

  1. 有什么问题?
  2. 没关系。完成引擎可能配置错误或使用旧标准 - 这意味着它不理解所有的提升 headers.

    mpl::vector 实际上只是一个 type-list,所以根本没有 "intellisense" 可以期待:你只能给它类型,编译器无法预测你想要什么类型。

    mpl::vector<int, double, std::string> 等同于 mpl::vector<>

  3. 重要的是你的编译器能理解它。所以,显然是这样。

    如果遇到运行时错误,请查找有关崩溃的信息。来自 link

    的代码
  4. 参见^

  5. 对啊,不然编译不出来

Q1

它确实识别 boost::mpl::vector 否则它不会编译。参见 2.

Q2

没有区别:两者都模拟完全相同的类型序列。一个是可变的,另一个 "number" (即具有固定长度):https://www.boost.org/doc/libs/1_66_0/libs/mpl/doc/refmanual/vector.html