
On 11/17/2010 1:50 PM, Eric Niebler wrote:
On 11/17/2010 4:24 PM, joel falcou wrote:
Binding algorithm to container type lessen genericity of code.
... but is sometimes done in practice when the generic framework doesn't provide the concepts for optimal implementations; e.g. std::map::lower_bound. In the STL, that would be the case with for_each over segmented sequences. A better solution, however, would be to define a concept for segmented iterators and write a generic segmented for_each algorithm.
Right. I almost read this as you suggesting to use segmented iterators for the OP's problem, but I don't think that's what you're suggesting. The OP's original problem (as I understand it) was to provide a generic framework to use thrust::for_each when working with thrust::vector's, boost::fusion::for_each when working with Boost.Fusion sequences, and std::for_each when using any STL-compatible range (the default, basically). Indeed, seems like this would just extend the idea of differentiating whether to dispatch to a std::for_each or a segmented for_each. I only meant to suggest that one would have to somehow tie the sequence to a particular iteration mechanism (i.e., a for_each implementation). The use of member function notation was a poor choice which kicked up more dust than I thought :/ - Jeff