Subject: Re: [boost] for_each abstraction
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2010-11-17 16:56:30
On 11/17/2010 10:42 PM, joel falcou wrote:
> On 17/11/10 22:35, Karsten Ahnert wrote:
>> Sure, but there is no to change the way how elements in a range are
>> iterated. In my example, the algorithm is entirely provided by for_each
>> with the appropriate operation.
> That's not the actual problem. Bindign such thing make codes cumbersome
> to use in
> generic context where you may or may not know if a T must sue for_each
> or T::for_each.
> The proper way to solve the original question while preserving
> genericity is to use tag dispatching
> and externally tagging each type supporting on for_each with a proper
> compile-time flag thanks to
> a proper meta-function then use it to select the implementation fo the
> global, free for_each function.
I think I understand. Maybe this allows the analogy to boost.range which
provides an extendable layer how sequences/containers can be used in the
range algorithms. Here an extendable layer is needed which allows you to
change the way how thinks are iterated in for_each ( or accumulate,
transform,... ), but with the additional contraint that the iteration
has to be choosen according to the sequence/container.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk