此代码无法编译(gcc 5.3.1 + boost 1.60):
#include <boost/spirit/home/x3.hpp>
namespace x3 = boost::spirit::x3;
template <typename T>
void parse(T begin, T end) {
auto dest = x3::lit('[') >> x3::int_ >> ';' >> x3::int_ >> ']';
auto on_portal = [&](auto& ctx) {};
auto portal = (x3::char_('P') >> -dest)[on_portal];
auto tiles = +portal;
x3::phrase_parse(begin, end, tiles, x3::eol);
}
int main() {
std::string x;
parse(x.begin(), x.end());
}
它以静态断言失败:
error: static assertion failed: Attribute does not have the expected size.
感谢 wandbox,我还尝试了 boost 1.61 和 clang,两者都产生了相同的结果。
如果我删除附加到的语义动作portal
,它编译得很好;如果我更改dest
为:
auto dest = x3::lit('[') >> x3::int_ >> ']';
任何帮助,将不胜感激。TIA。