Re: Passing Elements of A Static Array as Function Parameters

2015-09-14 Thread Meta via Digitalmars-d-learn
On Monday, 14 September 2015 at 09:09:27 UTC, Per Nordlöw wrote: Is there a reason why such a common thing isn't already in Phobos? If not what about adding it to std.typecons : asTuple I guess nobody's really needed that functionality before. It might be an interesting addition to std.array.

Re: Passing Elements of A Static Array as Function Parameters

2015-09-14 Thread Meta via Digitalmars-d-learn
On Monday, 14 September 2015 at 08:56:43 UTC, Per Nordlöw wrote: BTW: What about .tupleof? Isn't that what should be used here? I don't believe .tupleof works for arrays.

Re: Passing Elements of A Static Array as Function Parameters

2015-09-14 Thread Meta via Digitalmars-d-learn
On Monday, 14 September 2015 at 05:18:00 UTC, Nordlöw wrote: If I have a static array `x` defined as enum N = 3; int[N] x; how do I pass it's elements into a variadic function f(T...)(T xs) if (T.length >= 3) ? You could turn it into a Tuple and use the `expand` method to get

Re: Passing Elements of A Static Array as Function Parameters

2015-09-14 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 14 September 2015 at 07:05:23 UTC, Meta wrote: You could turn it into a Tuple and use the `expand` method to get a TypeTuple (AliasSeq). import std.typecons; import std.typetuple; import std.stdio; template genTypeList(T, size_t n) { static if (n <= 1) {

Re: Passing Elements of A Static Array as Function Parameters

2015-09-14 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 14 September 2015 at 07:05:23 UTC, Meta wrote: You could turn it into a Tuple and use the `expand` method to get a TypeTuple (AliasSeq). import std.typecons; import std.typetuple; import std.stdio; template genTypeList(T, size_t n) { static if (n <= 1) {

Passing Elements of A Static Array as Function Parameters

2015-09-13 Thread Nordlöw via Digitalmars-d-learn
If I have a static array `x` defined as enum N = 3; int[N] x; how do I pass it's elements into a variadic function f(T...)(T xs) if (T.length >= 3) ?