如何在VS2017中的boost spirit x3中制作递归规则

How to make a recursive rule in boost spirit x3 in VS2017

我在 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;
}

Coliru link, g++

Coliru link, clang++

如何在 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'

我查看了 GitHub 上的 Boost.Spirit 存储库,因为我的本地版本太旧,并注意到您的示例可以在最新的 develop 分支上正常编译,但不能在 1.66 上编译。 0 版本(也在 Clang 和 GCC 上)。将提交历史一分为二显示此错误已在

中修复

ee4943d5891bdae0706fb616b908e3bf528e0dfa

您可以将此提交中的补丁应用于您的安装或等待下一个版本。