下面的代码来自Boost.Spirit x3 documentation。它使用了一种有趣的C++语法,这是我以前从未见过的,如果不知道适当的术语,在搜索查询中几乎不可能描述这种语法。这是类的正向声明的简写吗?在C++标准中提到的这个特性在哪里?
namespace parser
{
using x3::eps;
using x3::lit;
using x3::_val;
using x3::_attr;
using ascii::char_;
auto set_zero = [&](auto& ctx){ _val(ctx) = 0; };
auto add1000 = [&](auto& ctx){ _val(ctx) += 1000; };
auto add = [&](auto& ctx){ _val(ctx) += _attr(ctx); };
// What is this? This is the very first use of the identifier `roman`.
x3::rule<class roman, unsigned> const roman = "roman";
// ^^^^^^^^^^^
auto const roman_def =
eps [set_zero]
>>
(
-(+lit('M') [add1000])
>> -hundreds [add]
>> -tens [add]
>> -ones [add]
)
;
BOOST_SPIRIT_DEFINE(roman);
}
https://stackoverflow.com/questions/39238879
复制相似问题