Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Larry Evans <cppljevans <at> suddenlink.net>
Subject: Re: another case for tagged variants (was Re: Look mom! No semantic actions.
Newsgroups: gmane.comp.parsers.spirit.general
Date: Tuesday 27th October 2009 03:57:00 UTC (over 7 years ago)
On 10/26/09 20:32, Michael Caisse wrote:
[snip]
> 
> I think you ask a good question. I hope somebody has a great
> solution for the general problem... however you could:
> 
>     typedef tuple< variant< int, string >, int >  rule_type;
> 
>     path %= (  ( int_ > attr( 0 ) )
>                |
>                ( regex_search > attr( 1 ) )
>                |
>                ( product_name > attr( 2 ) )
>             );
> 
> 
>     rule< Iterator, rule_type(), space_type > path;
> 
[snip]

Yep, that'll work; however, what it does is simply provide
a workaround for something that shouldn't have to be worked
around.  Also, it really wastes a little space.  The
variant already contains a tag (whose value is returned by
variant<...>::which() ); yet, the workaround duplicates
that tag with the 2nd element of the tuple.  With a truly
tagged variant, you wouldn't need the duplication nor would
you need to suffix each element in the | with the > attr(tag)
eps-like parser.

-regards,
Larry


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
 
CD: 3ms