Boost logo

Proto :

Subject: Re: [proto] Visitor Design Pattern
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-26 13:44:20


On 10/25/2010 10:11 PM, Joel.Falcou_at_[hidden] wrote:
>> or bundle it with the external transforms.
>> All you need is a nested when template. Does that help?
>
> A short example of this for my poor 7am self without coffee ;) ?

struct my_actions_with_state
{
    // specializations to look up transforms
    // using rules:
    template<typename Rule>
    struct when;

    // any ol' state can go here:
    int my_state;
};

Now, you can pass an instance of my_actions_with_state as a data
parameter. Proto will use the nested "when" template to find transforms,
and your transforms can use the my_state member at runtime to do whatever.

Does that help?

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Proto list run by eric at boostpro.com