On Fri, Feb 09, 2018 at 03:05:33PM +0000, Ralph Doncaster via
Digitalmars-d-learn wrote:
> This seems odd to me. Is there a way I can make a function that takes
> an array of any type but only of a specific size in bytes?
>
> void.d(8): Error: function void.foo (void[12] arr) is not callable
> using argument types (uint[3])
> Failed: ["/usr/bin/dmd", "-v", "-o-", "void.d", "-I."]
> void foo(void [12] arr)
> {
> }
>
> void main()
> {
> uint[3] arr;
> foo(arr);
> }
You probably didn't mean to pass a static array, because those are
passed by value and may entail unnecessary copying. (Though in this
case, if you're only expecting 12 bytes, that's not that big of a
difference.)
But in any case, probably something like this would do:
void foo(void[] arr)
in { assert(arr.length == 12); }
do {
...
}
T
--
If creativity is stifled by rigid discipline, then it is not true creativity.