How to cast arrays?

Matheus m at mail.com
Sat Mar 2 02:27:02 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.

By the way here is how:

void foo(){
    ubyte[] x = [1,2];
    auto y = (cast(int*) &x)[0..2];
    writeln(y);
}

Matheus.


More information about the Digitalmars-d-learn mailing list