boostorg / spirit

Boost.org spirit module
http://boost.org/libs/spirit
394 stars 162 forks source link

X3: sequence as container in container parser compilation error #714

Open Bockeman opened 2 years ago

Bockeman commented 2 years ago

MCVE:

#include <boost/spirit/home/x3.hpp>
#include <vector>
int main()
{
    using namespace boost::spirit::x3;
    char const* const s = "ab12", * const e = s + std::strlen(s);
    std::vector<std::vector<char>> v;
    parse(s, e, +(char_ >> char_), v);
}

Workaround by using an intermediate rule:

#include <boost/spirit/home/x3.hpp>
#include <vector>
int main()
{
    using namespace boost::spirit::x3;
    char const* const s = "ab12", * const e = s + std::strlen(s);
    std::vector<std::vector<char>> v;
    parse(s, e, +(rule<class BOOST_JOIN(rule_id_, __LINE__), std::vector<char>>{} = char_ >> char_), v);
}