On Friday, 9 February 2018 at 16:28:50 UTC, Nicholas Wilson wrote:
On Friday, 9 February 2018 at 15:50:24 UTC, Ralph Doncaster
wrote:
Is there a way I can make a function that takes an array of any
type but only of a specific size in bytes?
With a template that constrains the types size:
void foo(T)(T t) if (T.sizeof == 12)
{
//...
}
alternately reject incorrect values at runtime
void foo(ubyte[] t)
in
{
assert(t.length == 12);
}
do
{
//...
}
Thanks. That's what I thought. If I stick with using D, I'll
probably go with the runtime check.