using the full range of ubyte with iota
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 24 13:15:40 PST 2015
On Sat, 24 Jan 2015 20:49:01 +0000, Dominikus Dittes Scherkl wrote:
> Maybe I'm just too stupid, but I cannot manage to call a simple function
> with all 256 possible values of ubyte with iote:
>
> int foo(ubyte c);
>
> auto myRange = iota(0,256).map!foo;
>
> --> Error: function foo(ubyte c) is not callable using argument types
> (int)
>
> and this is because of the f*** end-type cannot be ubyte because in
> phobos everywhere end is excluded, so I have to define it too large by
> one.
>
> Has anyone any idea how to work around this?
> I would have no problem using an explicit cast, but where should I apply
> it?
auto myRange = iota(0, 256).map!(a => foo(cast(ubyte)a));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150124/5bda1207/attachment.sig>
More information about the Digitalmars-d-learn
mailing list