using the full range of ubyte with iota

Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 25 06:01:55 PST 2015


On Sunday, 25 January 2015 at 12:56:14 UTC, Tobias Pankrath wrote:
> On Sunday, 25 January 2015 at 12:25:35 UTC, Dominikus Dittes 
> Scherkl wrote:
>>
>> map!(x => fn(cast(ParameterTypeTuple!fn[0])x)
>>
>> but instead with
>>
>> map!(paramCast!fn)
>>
>> Because this is useful in more situations, e.g. in every place 
>> where you know the values would fit into the parameter (and 
>> for a single call would use a cast).
>>
>> But so far I couldn't manage to make this work :-/
>
> http://dpaste.dzfl.pl/07b1fa3c2dad

Hey cool.
With unary function I can even remove the string and mixin magic:

template paramCast(alias fn)
{
    ReturnType!fn paramCast(T)(T x)
    {
       return fn(cast(ParameterTypeTuple!fn[0])x);
    }
}

Many Thanks!


More information about the Digitalmars-d-learn mailing list