3

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.

chrisaycock
  • 36,470
  • 14
  • 88
  • 125

2 Answers2

4

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

    BOOST_FUSION_ADAPT_STRUCT(MyStruct, /**/);
SirGuy
  • 10,660
  • 2
  • 36
  • 66
0

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

Sebastian Redl
  • 69,373
  • 8
  • 123
  • 157