|
Boost : |
Subject: Re: [boost] [fusion] sequence member pointer
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-02-25 00:31:24
On 2/25/2011 1:07 PM, Daniel Larimer wrote:
>
> On Feb 24, 2011, at 11:09 PM, Joel de Guzman wrote:
>
>> On 2/25/2011 10:44 AM, Daniel Larimer wrote:
>>> I am attempting to use a fusion sequence with a visitor pattern that expects 'member function' or 'member data' pointers.
>>>
>>> What I would like to do is something like:
>>>
>>> &fusion::vector<int,double>::m1
>>>
>>> But obviously this cannot work because of how fusion::vector<int,double> is implemented with a single vector_n<...> vec data member that is private.
>>>
>>> So trying to "reflect" a vector in the same way that I "reflect" a struct does not work.
>>>
>>> Any good ideas? Is there any reason why this 'implementation detail' needs to be hidden?
>>
>> Well, the proper way is to use fusion::for_each(s) and you don't have to
>> care what the internal structure of s is. I highly suggest that you use
>> the fusion algorithms to walk through (visit) a fusion sequence.
>
> That is what I ended up doing, but it ends up being a special case.
It is the right thing to do. There is no guarantee that the
structs will have the same member names; unless it's documented.
But it is not, so you are relying on undocumented implementation
detail.
Regards,
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk