|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2006-08-31 19:18:30
David Abrahams wrote:
> Joel de Guzman <joel_at_[hidden]> writes:
>
>> There's also an interesting
>> use-case that became apparent recently: making arbitrary structs/classes
>> conforming sequences easily-- as easy as providing a single function.
>> Pardon me if this is rather sketchy at this point, but imagine
>> being able to write:
>>
>> Our user defined struct:
>>
>> struct point { float x, float y; };
>>
>> Customization:
>>
>> fusion::map<keys::x_, keys::y_, float&, float&>
>> as_fusion_sequence(point& p)
>> {
>> return fusion::map_tie<keys::x_, keys::y_>(p.x, p.y);
>> }
>>
>> Use:
>>
>> point p = { 123.456, 789.012 };
>> fusion::for_each(p, std::cout << _1 << std::endl);
>
> That's nice, but I don't think it's really the same thing. Doesn't it
> incur an extra level of indirection?
Not the same as what? Sorry, I think I missed something in
your question/comment.
Cheers,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk