static foreach and inline if

2013-07-27 Thread JS
I'd like to have foreach and inline if in templates: The tIf doesn't work properly but I'm not sure why template tuple(args...) { alias tuple = args; } template tIf(bool cond) { alias tIf = tuple!(); } template tIf(bool cond, alias T) { static if (cond) alias tIF = T; else alias tIF =

Re: static foreach and inline if

2013-07-27 Thread JS
BTW, it works with static if's, I'm trying to use an inline if to reduce redundant code since there is no static ?:.

Re: static foreach and inline if

2013-07-27 Thread monarch_dodra
On Saturday, 27 July 2013 at 17:15:54 UTC, JS wrote: BTW, it works with static if's, I'm trying to use an inline if to reduce redundant code since there is no static ?:. I don't really understand, since you didn't really explain *what* you were trying to do before pasting that code, but fo

Re: static foreach and inline if

2013-07-27 Thread anonymous
On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: The tIf doesn't work properly but I'm not sure why [...] template tIf(bool cond, alias T) Lower case 'f' here, ... { static if (cond) alias tIF = T; else alias tIF = tuple!(); ... upper case 'F's here.

Re: static foreach and inline if

2013-07-27 Thread JS
On Saturday, 27 July 2013 at 19:06:48 UTC, anonymous wrote: On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: The tIf doesn't work properly but I'm not sure why [...] template tIf(bool cond, alias T) Lower case 'f' here, ... { static if (cond) alias tIF = T; else alias tIF = tup

Re: static foreach and inline if

2013-07-28 Thread QAston
On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach and inline if in templates: inline if is available as std.traits.Select

Re: static foreach and inline if

2013-07-28 Thread JS
On Sunday, 28 July 2013 at 08:38:01 UTC, JS wrote: On Sunday, 28 July 2013 at 08:30:17 UTC, QAston wrote: On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach and inline if in templates: inline if is available as std.traits.Select This doesn't work for variadic args

Re: static foreach and inline if

2013-07-28 Thread JS
On Sunday, 28 July 2013 at 08:30:17 UTC, QAston wrote: On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach and inline if in templates: inline if is available as std.traits.Select This doesn't work for variadic args... Something Split!(Cond, targ..., split, fargs) i

Re: static foreach and inline if

2013-07-28 Thread JS
The following works but is somewhat of a hack... module main; import std.stdio, std.typetuple; struct tTupleSplit { } template tIndexOf(T, args...) { static if (staticIndexOf!(T, args) < 0) enum tIndexOf = args.length; else enum tIndexOf = staticIndexOf!(T, args); } template tMin(a

Re: static foreach and inline if

2013-07-28 Thread anonymous
On Sunday, 28 July 2013 at 08:38:40 UTC, JS wrote: On Sunday, 28 July 2013 at 08:38:01 UTC, JS wrote: On Sunday, 28 July 2013 at 08:30:17 UTC, QAston wrote: On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach and inline if in templates: inline if is available as std

Re: static foreach and inline if

2013-07-28 Thread JS
On Sunday, 28 July 2013 at 09:11:55 UTC, anonymous wrote: On Sunday, 28 July 2013 at 08:38:40 UTC, JS wrote: On Sunday, 28 July 2013 at 08:38:01 UTC, JS wrote: On Sunday, 28 July 2013 at 08:30:17 UTC, QAston wrote: On Saturday, 27 July 2013 at 17:14:35 UTC, JS wrote: I'd like to have foreach

Re: static foreach and inline if

2013-07-28 Thread monarch_dodra
On Sunday, 28 July 2013 at 15:33:48 UTC, JS wrote: I tried to do that with tuple which is identical to your wrap but was not successful... possibly because I did not unwrap it... It should work. You can expand the *types* with Types, and the *values* with expand.

Re: static foreach and inline if

2013-07-28 Thread anonymous
On Sunday, 28 July 2013 at 15:33:48 UTC, JS wrote: On Sunday, 28 July 2013 at 09:11:55 UTC, anonymous wrote: On Sunday, 28 July 2013 at 08:38:40 UTC, JS wrote: [...] template Wrap(Stuff ...) {alias unwrap = Stuff;} Select!(cond, Wrap!targs, Wrap!fargs).unwrap I tried to do that with tuple wh