Вопрос

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.

Это было полезно?

Решение

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

    BOOST_FUSION_ADAPT_STRUCT(MyStruct, /**/);

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top