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
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
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
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
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
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]
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