Re: strange CFTE issue

2017-04-09 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 9 April 2017 at 16:44:41 UTC, ag0aep6g wrote: Or you can make it a template value parameter [2] with type `string[]`: string[] sfilter(T, string[] fields)() { string[] result; foreach (f; aliasSeqOf!fields) { /* ... loop body as you have it ... */ }

Re: strange CFTE issue

2017-04-09 Thread ag0aep6g via Digitalmars-d-learn
On 04/09/2017 04:36 PM, Boris-Barboris wrote: Hello, I have a similar problem. For the life of me I can't make CTFE work while manipulating collections. Source: This post is only loosely related to the thread. Generally, please make a new thread for a new problem. import std.meta; import

Re: strange CFTE issue

2017-04-09 Thread Boris-Barboris via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 17:27:35 UTC, ag0aep6g wrote: Phobos has it: std.meta.aliasSeqOf "converts an input range [...] to an alias sequence." [1] Woops, forgot to give the URL for that "[1]". Here it is: http://dlang.org/phobos/std_meta.html#aliasSeqOf Hello, I have a similar

Re: strange CFTE issue

2017-03-15 Thread ag0aep6g via Digitalmars-d-learn
Phobos has it: std.meta.aliasSeqOf "converts an input range [...] to an alias sequence." [1] Woops, forgot to give the URL for that "[1]". Here it is: http://dlang.org/phobos/std_meta.html#aliasSeqOf

Re: strange CFTE issue

2017-03-15 Thread ag0aep6g via Digitalmars-d-learn
On 03/15/2017 02:00 PM, Inquie wrote: Thanks, it explains it, but there is one difference. The array is assigned to an enum, so surely the compiler can figure that out? It should be similar to AliasSeq. The enum array is similar to an AliasSeq in that you can them both in contexts that

Re: strange CFTE issue

2017-03-15 Thread Inquie via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 03:40:42 UTC, ag0aep6g wrote: On 03/15/2017 03:01 AM, Inquie wrote: If I do something like enum X = Methods!(C); foreach(x; X) { mixin(x); } I get an error about x not being a compile time variable. (code above is simplified, the error has nothing to do

Re: strange CFTE issue

2017-03-14 Thread ag0aep6g via Digitalmars-d-learn
On 03/15/2017 03:01 AM, Inquie wrote: If I do something like enum X = Methods!(C); foreach(x; X) { mixin(x); } I get an error about x not being a compile time variable. (code above is simplified, the error has nothing to do with the form but of the foreach(x ) "Compile time variable"

strange CFTE issue

2017-03-14 Thread Inquie via Digitalmars-d-learn
If I do something like enum X = Methods!(C); foreach(x; X) { mixin(x); } I get an error about x not being a compile time variable. (code above is simplified, the error has nothing to do with the form but of the foreach(x ) but if I wrap it in a function it works string foo() { enum X