how to do iota(0,256) with ubytes ? (cf need for iotaInclusive)
Dmitry Olshansky via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 8 22:31:50 PDT 2015
On 09-Oct-2015 05:43, Timothee Cour via Digitalmars-d wrote:
> also, workarounds involving:
> iota(0,256).map!(a=>cast(ubyte)a)
> are neither pleasant nor efficient
>
Anything less then 32/64-bit is actually a tiny bit slower due to having
to mask away top 8/16 bits since most of parameters passing and
arithmetic is done on full words. Anyhow cast is 0-cost.
>
> On Thu, Oct 8, 2015 at 7:41 PM, Timothee Cour <thelastmammoth at gmail.com
> <mailto:thelastmammoth at gmail.com>> wrote:
>
> how to do iota(0,256) with ubytes ?
> and more generally:
> iota with 'end' parameter set to max range of a type.
>
> of course this doesn't work:
> auto b=iota(ubyte(0), ubyte(256));
> //cannot implicitly convert expression (256) of type int to ubyte
>
> Could we have a function with iota_inclusive that has inclusive
> bounds for 'end' parameter ?
>
>
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list