
On Fri, Jan 15, 2010 at 3:17 AM, Cory Nelson
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]