using the full range of ubyte with iota
Tobias Pankrath via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 24 13:00:02 PST 2015
On Saturday, 24 January 2015 at 20:49:03 UTC, 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?
iota(0, 256).map!(x => foo(cast(ubyte) x))
More information about the Digitalmars-d-learn
mailing list