uint[3] not equivalent to void[12]?
Mike Parker
aldacron at gmail.com
Fri Feb 9 15:27:35 UTC 2018
On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote:
>
> ====
> import std.stdio;
>
> enum numBytes = 12;
> void foo(T, size_t N)(T[N] arr)
> if((N * T.sizeof) == numBytes)
> {
> writeln(arr);
> }
>
> void bar(ubyte[12] arr)
> {
> writeln(arr);
> }
Also, it's worth mentioning in case you aren't aware that this
can be expensive, depending on the size of the array. Static
arrays are passed by value. You may want to make the arr
parameters ref or, if you want to protect the contents, const ref:
void foo(T, size_t N)(ref const(T)[N] arr)
More information about the Digitalmars-d-learn
mailing list