chrisaycock
chrisaycock

Reputation: 37928

Adapting an empty struct for Boost Fusion

I have an empty struct:

struct MyStruct {};

I want to adapt this to be used by Boost Fusion. Ordinarily I would use BOOST_FUSION_ADAPT_STRUCT, but this macro requires two parameters to name the struct and list its fields. Is there anyway to tell the macro that the fields are non-existent?

Motivation: I am using Boost Spirit to define a parser. The struct is for a boost::variant that is then passed to boost::apply_visitor(). Some of the other items in the variant given the boost::fusion::for_each() treatment.

Upvotes: 3

Views: 611

Answers (2)

SirGuy
SirGuy

Reputation: 10780

I tried passing /**/ as the second parameter and it compiled for me (g++-4.6.2).

    BOOST_FUSION_ADAPT_STRUCT(MyStruct, /**/);

Upvotes: 4

Sebastian Redl
Sebastian Redl

Reputation: 72044

Try passing BOOST_PP_EMPTY. No guarantees that it will work, but given the implementation it seems likely.

Upvotes: 0

Related Questions