How to cast arrays?

Matheus m at mail.com
Sat Mar 2 02:20:44 UTC 2019


On Saturday, 2 March 2019 at 02:14:01 UTC, Murilo wrote:
> How do I cast a ubyte[] into uint[]? It keeps raising an error, 
> I have read the documentation saying there are restrictions for 
> that concerning the length of the arrays.

https://dlang.org/spec/expression.html#cast_expressions

"Casting a dynamic array to another dynamic array is done only if 
the array lengths multiplied by the element sizes match. The cast 
is done as a type paint, with the array length adjusted to match 
any change in element size. If there's not a match, a runtime 
error is generated."

Matheus.


More information about the Digitalmars-d-learn mailing list