Boost logo

Boost Users :

Subject: [Boost-users] [Fusion] Adapted struct with member optional<variant<A, B>> needs typedef
From: PB (newbarker_at_[hidden])
Date: 2010-09-27 07:28:05


Hello,

The following program (written in VS2008/VC9 with Boost 1.44) doesn't compile:

#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/optional.hpp>
#include <boost/variant/variant.hpp>

#include <string>
#include <vector>

struct Word {std::string str;};

struct Text {std::string str;};

struct Transition
{
        boost::optional<boost::variant<Word,Text>> token;
};

BOOST_FUSION_ADAPT_STRUCT(Word,(std::string, str))

BOOST_FUSION_ADAPT_STRUCT(Text,(std::string, str))

BOOST_FUSION_ADAPT_STRUCT(
    Transition,
        (boost::optional<boost::variant<Word,Text>>, token)
)

int main(int argc,char *argv[])
{
        return 0;
}

Compiler output:
error warning C4002: too many actual parameters for macro
'BOOST_FUSION_ADAPT_STRUCT_FILLER_0'.
<etc>

If I introduce a typedef for the long type:

typedef boost::optional<boost::variant<Word,Text>> TokenType;

and change the adapt struct to use the shorter name, it works:

BOOST_FUSION_ADAPT_STRUCT(
    Transition,
        (TokenType, token)
)

Why is this, and what are the constraints on the types fed to
BOOST_FUSION_ADAPT_STRUCT?

Thanks,

Pete


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net