|
Boost Users : |
Subject: Re: [Boost-users] [karma] using attributes out of order
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-01-15 06:00:41
On Fri, Jan 15, 2010 at 3:17 AM, Cory Nelson <phrosty_at_[hidden]> wrote:
> Hello,
>
> I was fairly familiar with Spirit 1, but I'm now making my first foray
> into Spirit 2. Â I'm trying to write something with karma's attribute
> system. Â Say I've got a fusion adapted struct:
>
> struct s { int foo; double bar; std::string baz; };
>
> The Spirit docs give plenty of examples like:
>
> int_ << double_ << string
>
> But I can't find any docs showing how to output the members in a
> different order, like:
>
> double_ << string << int_
>
> Is there a recommended way to achieve this? Â Thanks!
It is generally better to ask these questions on the Spirit mailing list.
However, three immediate answers to that from what I can see right off the bat.
First:
When you specify you struct as the BOOST_FUSION_ADAPT_STRUCT or
whatever it is called, you can specify your order in that.
Second:
You can use Fusion to operate over the struct to give things a different order.
Third:
You can use actors, unsure if this code is correct, but it is like this:
double_[_2] << string[_3] << int_[_1]
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net