|
Boost Users : |
Subject: Re: [Boost-users] [Fusion] Adapted struct with member optional<variant<A, B>> needs typedef
From: PB (newbarker_at_[hidden])
Date: 2010-09-27 16:20:26
On Mon, Sep 27, 2010 at 7:26 PM, Christopher Schmidt
<mr.chr.schmidt_at_[hidden]> wrote:
> PB schrieb:
>> On Mon, Sep 27, 2010 at 5:19 PM, Nathan Crookston
>> <nathan.crookston_at_[hidden]> wrote:
>>> Hi Pete,
>>>
>>> On Mon, Sep 27, 2010 at 5:28 AM, PB <newbarker_at_[hidden]> wrote:
>>> <snip code>
>>>> BOOST_FUSION_ADAPT_STRUCT(
>>>> Transition,
>>>> (boost::optional<boost::variant<Word,Text>>, token)
>>>> )
>>> <snip code>
>>>> Compiler output:
>>>> error warning C4002: too many actual parameters for macro
>>>> 'BOOST_FUSION_ADAPT_STRUCT_FILLER_0'.
>>>> <etc>
>>>
>>>> Why is this, and what are the constraints on the types fed to
>>>> BOOST_FUSION_ADAPT_STRUCT?
>>>
>>> The problem seems to be that the preprocessor is seeing the ',' in
>>> boost::variant and is parsing it like a tuple of 3 objects:
>>> "boost::optional<boost::variant<Word," "Text>>" and "token", while
>>> Boost.Fusion expects 2 objects. The normal solution is to add a set
>>> of parentheses around the token with a comma, but that doesn't seem to
>>> work here. I think your typedef solution is probably the simplest and
>>> best for this case -- but my skills with the preprocessor are
>>> definitely incomplete.
>>
>> Nate,
>>
>> Ahh. I didn't think about the comma. Perhaps the
>> BOOST_FUSION_ADAPT_STRUCT macro itself needs some parentheses
>> internally.
>>
>> I'll stick to the typedef but hopefully if this can be fixed, the
>> right people are viewing this topic.
>
> I think this issue cannot be fixed. Is there a method to extract a type
> from a parenthesized type expression without losing cv-qualifiers?
> BTW. this issue already came up a few times. Paul Mensonides summed it
> up pretty well 7 years ago:
>
> http://article.gmane.org/gmane.comp.lib.boost.devel/84424
Christopher,
Thanks for the link. It's all clear now.
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