Transforming a range back to the original type?

Jacob Carlborg doob at me.com
Thu May 3 01:41:50 PDT 2012


On 2012-05-02 23:40, Jonathan M Davis wrote:
> On Wednesday, May 02, 2012 23:01:21 Jacob Carlborg wrote:
>> Is there a general function for transforming a range back to the
>> original type? If not, would it be possible to create one?
>
> You mean that if you have something like
>
> auto range = getRangeFromSomewhere();
> auto newRange = find(filter!func(range), value);
>
> you want to transform newRange back to the same type as range?

No, I want to transform newRange back to a collection, the same type as 
the original collection. I was thinking something like this:

Collection c = new Collection();
c = c.filter!(x => x < 3).toCollection();

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list