Transforming a range back to the original type?

Jakob Ovrum jakobovrum at gmail.com
Fri May 4 06:06:31 PDT 2012


On Friday, 4 May 2012 at 12:49:35 UTC, Steven Schveighoffer wrote:
> or more generically:
>
> c = new typeof(c)(c.filter!(x => x < 3));
>
> ?

That doesn't do the right thing when 'c' isn't a class type, so 
it's not really that generic.

Struct types (the type of `new typeof(c)` is not `typeof(c)`!) 
and array types simply fail with your suggestion.

I personally haven't decided whether I think a generic convention 
is useful here, but that code doesn't fit the bill.



More information about the Digitalmars-d-learn mailing list