在一个简单的解析器测试Live On Coliru中,
std::string str("x123x");
boost::iterator_range<boost::range_iterator<decltype(str)>::type> attr;
if( x3::parse( boost::begin(str), boost::end(str), x3::lit('x') >> x3::raw[+x3::digit] >> x3::lit('x'), attr ) ) {
std::cout<<"Match! attr = "<<attr<<std::endl;
} else {
std::cout<<"Not match!"<<std::endl;
}
解析器
x3::lit('x') >> x3::raw[+x3::digit] >> x3::lit('x')
应该合成一个 type 的属性boost::iterator_range<Iterator>
。但它无法编译。如果我们删除两者中的任何一个x3::lit('x')
,它就会编译。尽管Live on Coliru ,但相同的代码可以用 qi 编译。