Boost Spirit parser with inherited attributes - simple example won't compile

心已入冬 提交于 2019-11-29 17:30:28
cv_and_he

I've tried to construct an example here. I'm not sure I've faced the same issues you have(since you didn't provide a way to reproduce them) but I think there were two different problems: The first one, very common, is that PhoenixV2 does not work with "modern compilers" since the breaking change in Boost 1.52 that made BOOST_RESULT_OF_USE_DECLTYPE the default. There are two ways to solve this (at least with the clang version that coliru uses) either use V3 by defining BOOST_SPIRIT_USE_PHOENIX_V3(this is what I would recommend, and I think it should be the default) or return the result_of protocol to the behaviour V2 expects by defining BOOST_RESULT_OF_USE_TR1. The second problem, of which I'm not as familiarized so take this with a grain of salt or simply wait for an answer from "someone" more experienced, is that it seems that you can't pass string literals directly as an inherited attribute, you need to pass them as a string (using phx::val("foo") also seems to work).

Short version: Define BOOST_SPIRIT_USE_PHOENIX_V3 and pass your inherited attributes as a std::string not as a string literal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!