Bor*_*der 5 c++ boost-spirit-x3 visual-studio-2017
我在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;
}
Run Code Online (Sandbox Code Playgroud)
如何在VS2017中完成这项工作(如果可能)?
PS:Platform Toolset设置为v141,ISO标准设置为C++ 17,boost版本为1.66.0
PPS:编译错误如下
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'
Run Code Online (Sandbox Code Playgroud)
我检查了GitHub上的Boost.Spirit存储库,因为我的本地版本太旧了,并注意到你的示例使用最新的develop分支编译好,但没有1.66.0版本(也在Clang和GCC上).将提交历史记录分开,发现此错误已修复
您可以将此提交中的修补程序应用于您的安装,也可以等待下一个版本.