Re: Map one tuple to another Tuple of different type

2014-07-22 Thread Vlad Levenfeld via Digitalmars-d-learn
I'm just confused about how static while is supposed to work because static foreach, to my understanding, would have to work by making a new type for each iteration. I say this because, 1) runtime foreach works like that (with type = range), and 2) without ctfe foreach, the only way I know of

Re: Map one tuple to another Tuple of different type

2014-07-22 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 22, 2014 at 03:52:14PM +, Vlad Levenfeld via Digitalmars-d-learn wrote: I'm just confused about how static while is supposed to work because static foreach, to my understanding, would have to work by making a new type for each iteration. I say this because, 1) runtime foreach

Re: Map one tuple to another Tuple of different type

2014-07-22 Thread via Digitalmars-d-learn
On Tuesday, 22 July 2014 at 16:42:14 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jul 22, 2014 at 03:52:14PM +, Vlad Levenfeld via Digitalmars-d-learn wrote: Anyway my actual question is: if all values are constant at compile time, how would a static while loop terminate?

Re: Map one tuple to another Tuple of different type

2014-07-22 Thread Vlad Levenfeld via Digitalmars-d-learn
Yes, though the loop unrolling is news to me. I'll have to keep that in mind next time I'm trying to squeeze some extra performance out of a loop. btw, found a static switch enhancement request here: https://issues.dlang.org/show_bug.cgi?id=6921

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Vlad Levenfeld via Digitalmars-d-learn
Thats real weird that it would reject your i variable, given that T.length is known at compile time. I think this is a bug. I can get your code to compile if I change your foreach loop to this: foreach(i, U; T) modTuple[i] = transTupleElem(argTuple[i]); // ok

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Monday, 21 July 2014 at 01:29:40 UTC, Daniel Gibson wrote: Am 21.07.2014 03:05, schrieb Vlad Levenfeld: Thats real weird that it would reject your i variable, given that T.length is known at compile time. I think this is a bug. I can get your code to compile if I change your foreach loop

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread TheFlyingFiddle via Digitalmars-d-learn
On Monday, 21 July 2014 at 15:04:14 UTC, TheFlyingFiddle wrote: //Outputs 1 to 10 at compile-time. Edit: 0 to 9

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Daniel Gibson via Digitalmars-d-learn
Am 21.07.2014 17:04, schrieb TheFlyingFiddle: On Monday, 21 July 2014 at 01:42:58 UTC, Daniel Gibson wrote: Am 21.07.2014 03:34, schrieb Vlad Levenfeld: To get a foreach to run at compile-time, you have to give it something whose value is known to the compiler (so, T and typeof(argTuple) would

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 21, 2014 at 12:55:34AM +0200, Daniel Gibson via Digitalmars-d-learn wrote: Hi, I have a variadic templated function and want to call a C varargs function. I want to be able to pass static arrays, which D2 passes by value and C by reference, so I'd like to automagically translate

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 21, 2014 at 06:36:04PM +0200, Daniel Gibson via Digitalmars-d-learn wrote: [...] However, having something like staticIota in the stdlib would probably make sense. [...] It's already in std.typecons. (Admittedly, that's not exactly the most obvious place to look for it...) T --

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: It's already in std.typecons. But it is not online yet? Bye, bearophile

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Daniel Gibson via Digitalmars-d-learn
Am 21.07.2014 20:09, schrieb H. S. Teoh via Digitalmars-d-learn: On Mon, Jul 21, 2014 at 06:36:04PM +0200, Daniel Gibson via Digitalmars-d-learn wrote: [...] However, having something like staticIota in the stdlib would probably make sense. [...] It's already in std.typecons. (Admittedly,

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Monday, 21 July 2014 at 18:10:14 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Jul 21, 2014 at 12:55:34AM +0200, Daniel Gibson via Digitalmars-d-learn wrote: Hi, I have a variadic templated function and want to call a C varargs function. I want to be able to pass static arrays,

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Monday, 21 July 2014 at 19:02:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote: functionality is desirable. Maybe we should rouse a racket on the main D forum to either make staticIota public, or implement static foreach. ;-) static switch would be so sick. I frequently find myself doing

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 22, 2014 at 02:47:51AM +, Vlad Levenfeld via Digitalmars-d-learn wrote: On Monday, 21 July 2014 at 19:02:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote: functionality is desirable. Maybe we should rouse a racket on the main D forum to either make staticIota public, or