Attribute of >> operator not following the rules (unless I'm missing something)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Attribute of >> operator not following the rules (unless I'm missing something)

Kees-Jan Dijkzeul
I have a trivial struct, adapted for boost::fusion:

struct Node
{
  std::string text;
};

BOOST_FUSION_ADAPT_STRUCT(Node, (std::string, text))

I have a grammar with a set of rules:

qi::rule<Iterator, Node()> node_line;
qi::rule<Iterator, Node()> node;

And there is one rule that blows up in my face:

node_line %= "  * " >> node;

I would expect this to be valid, since the attribute of the literal is
unused, and node_line and node have the same attribute type. Instead
the compiler complains:

/usr/include/boost/spirit/home/support/container.hpp:262:13: error: no
matching function for call to
‘std::basic_string<char>::insert(std::basic_string<char>::iterator,
const Node&)’

I.e. the compiler tries to append a struct Node onto a std::string. I
am utterly confused as to why it would try to do that. Any thoughts?

For a full program showing this problem, as well as the full compiler
error, please visit
http://stackoverflow.com/questions/26507932/boostspirit-attribute-types-not-collapsing

Thanks very much!

Kees-Jan

------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Attribute of >> operator not following the rules (unless I'm missing something)

Joel de Guzman
On 10/23/14, 6:22 PM, Kees-Jan Dijkzeul wrote:

> I have a trivial struct, adapted for boost::fusion:
>
> struct Node
> {
>    std::string text;
> };
>
> BOOST_FUSION_ADAPT_STRUCT(Node, (std::string, text))
>
> I have a grammar with a set of rules:
>
> qi::rule<Iterator, Node()> node_line;
> qi::rule<Iterator, Node()> node;
>
> And there is one rule that blows up in my face:
>
> node_line %= "  * " >> node;
>
> I would expect this to be valid, since the attribute of the literal is
> unused, and node_line and node have the same attribute type. Instead
> the compiler complains:
>
> /usr/include/boost/spirit/home/support/container.hpp:262:13: error: no
> matching function for call to
> ‘std::basic_string<char>::insert(std::basic_string<char>::iterator,
> const Node&)’
>
> I.e. the compiler tries to append a struct Node onto a std::string. I
> am utterly confused as to why it would try to do that. Any thoughts?
>
> For a full program showing this problem, as well as the full compiler
> error, please visit
> http://stackoverflow.com/questions/26507932/boostspirit-attribute-types-not-collapsing

You found a bug. I am working on it. I found where that is happening (
the compiler tries to append a struct Node onto a std::string), and I know
how to fix it, but I just want to be sure that my fix will not affect
other code, in general.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general