【发布时间】:2018-01-23 01:49:50
【问题描述】:
我在 boost::spirit::x3 中编写了以下递归规则,但它似乎只能在 g++/clang 中编译,而不是 VS2017 (15.5.3):
#include <iostream>
#include <boost/spirit/home/x3.hpp>
namespace lex3
{
namespace x3 = boost::spirit::x3;
x3::rule<struct foo_class> const foo = "foo";
x3::rule<struct bar_class> const bar = "bar";
auto bar_def = *((x3::char_ - "/*") - "*/") >> *(foo > *((x3::char_ - "/*") - "*/"));
auto foo_def = "/*" > bar > "*/";
BOOST_SPIRIT_DEFINE(foo)
BOOST_SPIRIT_DEFINE(bar)
}
int main(int argc, char** argv)
{
std::string input = "/* a /* nested */ comment */";
auto f = input.begin();
auto l = input.end();
if (parse(f, l, lex3::foo) && (f == l))
std::cout << "Parse success.\n";
else
std::cout << "Parse failure (remainder: " << std::string(f, l) << ").\n";
return 0;
}
如何在 VS2017 中完成这项工作(如果可能)?
P.S:Platform Toolset 设置为 v141,ISO 标准设置为 C++17,boost 版本为 1.66.0
P.P.S:编译错误如下
error C2039: 'insert': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
error C2039: 'end': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
error C2039: 'begin': is not a member of 'boost::spirit::x3::unused_type'
note: see declaration of 'boost::spirit::x3::unused_type'
【问题讨论】:
-
这是 Spirit 中的一个错误。这是修复:github.com/boostorg/spirit/commit/…
-
似乎确实如此。如果你回答这个问题,我会在早上投票/接受。
标签: c++ visual-studio-2017 boost-spirit-x3