且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

语义动作在 boost::spirit 解析中多次运行

更新时间:2023-11-12 21:26:40

即使稍后有回溯,也会触发语义操作.

Semantic actions fire even if there's backtracking later.

解析器表达式可能会抛出异常.

Parser expressions might throw.

仅出于这些原因,在语义操作中进行动态分配并不是一个好主意.如果需要,请使用智能指针(尽管这仍然效率低下).

For these reasons alone, it's not a good idea to do dynamic allocations in your semantic actions. If you need to, use smart pointers (though this will still be inefficient).