You seem to have stumbled on the inverse of the infamous single-element fusion sequence conundrum[1] :(
I noticed, because the error emanates from the code trying to verify that the input string matches the attribute (lit.hpp):
// fail if attribute isn't matched by immediate literal
typedef typename attribute<Context>::type attribute_type;
typedef typename spirit::result_of::extract_from<attribute_type, Attribute>::type
extracted_string_type;
using spirit::traits::get_c_string;
if (!detail::string_compare(
get_c_string(
traits::extract_from<attribute_type>(attr, context))
, get_c_string(str_), char_encoding(), Tag()))
{
return false;
}
However, that makes no sense at all, since the docs state:
lit
, likestring
, also emits a string of characters. The main difference is thatlit
does not consumes [sic] an attribute. A plain string like"hello"
or astd::basic_string
is equivalent to alit
So I just... on a whim thought to coerce things a little, by using the same workaround that works for single-element fusion sequences on the Qi side:
query = karma::eps << "yeah";
And, voilà: it works: Live On Coliru
[1] See
- How do I use a class with only one attribute in a AST with Boost Spirit?
- Spirit Qi attribute propagation issue with single-member struct
- Compiler error when adapting struct with BOOST_FUSION_ADAPT_STRUCT
- Adapt class containing a string member as synthesized attribute
Etc. This is a sad flaw that will probably need to be worked around for SpiritV2.