[fusion] Using fusion::at_c on a sequence or an unused type
Hi,
I'm working on finalizing an extension to spirit/qi in which I need to
extract an attribute from a fusion sequence in a parser context.
The problem I'm facing is that this parser attribute can be an unused
type or a valid fusion sequence.
Just to illustrate my problem:
template
On 11/10/2010 6:01 AM, teajay wrote:
Hi,
I'm working on finalizing an extension to spirit/qi in which I need to extract an attribute from a fusion sequence in a parser context. The problem I'm facing is that this parser attribute can be an unused type or a valid fusion sequence.
Just to illustrate my problem:
template
struct parser_dispachter { template <typename Index> void parse(Index &idx, Attribute &attr) { fusion::at_cIndex::value(Elements).parse(fusion::at_cIndex::value(attr)); } };
I actually have two cases: 1. Attribute = unused_type -> at_c replacement should return unused 2. Attribute = fusion sequence -> at_c replacement should return the corresponding attribute reference.
What would be the best solution to extract the give attribute ?
Thomas, Spirit::support already takes care of that. See attribute_of, attribute_not_unused, filter_unused_attributes and friends in in support/attributes.hpp. See how they are used. HTH Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
Le 10/11/2010 01:08, Joel de Guzman a écrit :
On 11/10/2010 6:01 AM, teajay wrote:
Hi,
I'm working on finalizing an extension to spirit/qi in which I need to extract an attribute from a fusion sequence in a parser context. The problem I'm facing is that this parser attribute can be an unused type or a valid fusion sequence.
Just to illustrate my problem:
template
struct parser_dispachter { template <typename Index> void parse(Index &idx, Attribute &attr) { fusion::at_cIndex::value(Elements).parse(fusion::at_cIndex::value(attr)); } };
I actually have two cases: 1. Attribute = unused_type -> at_c replacement should return unused 2. Attribute = fusion sequence -> at_c replacement should return the corresponding attribute reference.
What would be the best solution to extract the give attribute ?
Thomas, Spirit::support already takes care of that. See attribute_of, attribute_not_unused, filter_unused_attributes and friends in in support/attributes.hpp. See how they are used.
HTH
Regards, Hi Joel,
I'm aware of the templates you mention. I already use them in the solution I got working but I hoped there would be some better solution than what I have right now. I guess I found my answer in the usages of those templates: there's nothing better than what I have right now. So I'll leave it is. Thanks for the help. Thomas Bernard
participants (2)
-
Joel de Guzman
-
teajay