Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 09, 2018 at 03:05:33PM +, 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 > u

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
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

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:50:24 UTC, Ralph Doncaster wrote: On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but on

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster 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.f

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
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

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster 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]

uint[3] not equivalent to void[12]?

2018-02-09 Thread Ralph Doncaster via Digitalmars-d-learn
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(vo