[Spirit] [Fusion] Concise way to construct attribute object

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Spirit] [Fusion] Concise way to construct attribute object

Boost - Users mailing list
Dear Experts,

I currently have something like:

struct S {
   string name;
   string value;


using S_rule = qi::rule<ITER, skipper, S()>;

S_rule r %= identifier >> lit(':') >> identifier;

Note that I can use %= here and I don't need to write an explicit
semantic action to assign to S.

Now say I modify S:

class S
   S(string name_, string value_);
   // May be default-constructable, copyable, assignable etc.
   // - but name and value are not individually assignable.

Question: what is the best way to use that with the qi parser rule?

I was hoping to find something in Fusion that would allow me to adapt the
new class so that it can be used with %= as before, but I don't see anything

Currently the best that I can think of is:

S_rule r = ( identifier >> lit(':') >> identifier )
            [ _val = boost::phoenix::construct<S>(_1,_2) ];

How can I improve on that?

Thanks, Phil.

Boost-users mailing list
[hidden email]