Eliminate redundancy of dup/idup

Timon Gehr timon.gehr at gmx.ch
Sun Sep 9 09:47:58 PDT 2012


On 09/09/2012 06:37 PM, Piotr Szturmaj wrote:
> Timon Gehr wrote:
>> -1 for removing .idup, it is handy.
>
> auto idup(E)(const(E)[] arr) pure @trusted
> {
>      immutable result = arr.dup();
>      return result;
> }
>

auto idup(E)(const(E)[] arr) pure nothrow @safe
if(is(typeof({immutable r=arr.dup;}))){
     return cast()cast(immutable)arr.dup;
}

> :-)




More information about the Digitalmars-d mailing list