Boost logo

Boost :

Subject: Re: [boost] for_each abstraction
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-11-17 16:18:55


On 11/17/2010 01:05 PM, vicente.botet wrote:
> ----- Original Message -----
> From: "Jeffrey Lee Hellrung, Jr."<jhellrung_at_[hidden]>
> To:<boost_at_[hidden]>
> Sent: Wednesday, November 17, 2010 9:58 PM
> Subject: Re: [boost] for_each abstraction
>
>> I was imagining something slightly different, where the for_each
>> functions are more tightly coupled to the sequence types. In other
>> words, std::vector and thrust::device_vector both have a for_each member
>> function (or maybe a less intrusive for_each free function found, for
>> example, via ADL):
>>
>> std::vector< double> vec1;
>> vec1.for_each(op());
>> thrust::device_vector< double> vec2;
>> vec2.for_each(op());
>
> Please, don't add algorithms in the containers.

Are you objecting to the syntax or to the entire idea of letting
sequences opt in for tighter control of their iteration?

I'm not 100% convinced it's a good idea, but I'm not convinced it's a
bad idea either. It appears (to me, at least) to be one solution to the
OP's question, and to Mathias/Joel's problem with "packing" range
elements together to vectorize operations.

It also could (speculation) make iterating over a type-erased range more
efficient, compared to using type-erased iterators.

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk