How to convert ubyte[] to uint?
Steven Schveighoffer
schveiguy at yahoo.com
Wed May 23 19:59:21 UTC 2018
On 5/23/18 3:53 PM, Dr.No wrote:
> On Wednesday, 23 May 2018 at 19:49:27 UTC, Jonathan M Davis wrote:
>> On Wednesday, May 23, 2018 19:36:07 Dr.No via Digitalmars-d-learn wrote:
>>> [...]
>>
>> As the template constraint in the error message says, read requires an
>> input range. Static arrays are not input ranges. You need to give it a
>> dynamic array - and since read takes its argument by reference, you
>> can't simply slice the static array and pass it. You need a variable
>> that's a dynamic array.
>>
>> - Jonathan M Davis
>
> sorry, the error message wasn't clear to me. When I use dynamic arrays I
> get:
>
> slice of static array temporary returned by fnv64.finish() assigned to
> longer lived variable arr
>
> What should use instead of?
I'm guessing you wrote:
ubyte[] arr = fnv64.finish();
??
You want:
auto arrtmp = fnv64.finish();
auto arr = arrtmp[];
Basically, what you were doing is allocating some stack space to hold a
static array that immediately goes out of scope, and then storing a
slice to it.
-Steve
More information about the Digitalmars-d-learn
mailing list