Can Spirit parsers be used with auto?
auto bracketed_z = '[' >> +qi::char_('z') >> ']';
When assigning a parser to an auto variable, as shown above, the code crashes with a segmentation fault. However, passing the parser directly to qi::parse() inline works fine.
No, Spirit parsers are not intended to be used with auto in Spirit V2.
The underlying Proto expression templates hold references to temporaries. Assigning a parser to an auto variable causes the parser to be copied, which may result in dangling references.
To work around this issue, you can use the following methods:
The above is the detailed content of Can Spirit Parsers Be Used with `auto` Variables?. For more information, please follow other related articles on the PHP Chinese website!