Re: Weird template instantiation problem

2017-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/17 11:31 AM, Arafel wrote: As you can see, the only change is the type the function returns, but I don't see how it should make any difference. Also, changing from "enum" to "static immutable", or even removing the "enum" and directly embedding the function literal doesn't seem to make

Re: Weird template instantiation problem

2017-06-13 Thread Arafel via Digitalmars-d-learn
Well, I had kind of found a workaround (changing the return type to return the element and not the index) which I didn't like too much (what if there are duplicates?). Now that I've found a "proper" workaround well, I'm still interested in knowing the reason, if possible, or if it's a

Re: Weird template instantiation problem

2017-06-12 Thread ketmar via Digitalmars-d-learn
Arafel wrote: I actually found a workaround for the original issue: yeah, sorry for not proposing a workaround: i thought that you already did it, and now you're just interested why the original code doesn't work. ;-) i think that this is a bug (or, rather, unimplemented feature).

Re: Weird template instantiation problem

2017-06-12 Thread Arafel via Digitalmars-d-learn
On Monday, 12 June 2017 at 19:23:10 UTC, ketmar wrote: p.s.: while i understand the technical reason for second error message, it is still random and confusing. I think the reason for the typeof problem is that it works with expressions, not with types (so, typeof (int) is also not valid),

Re: Weird template instantiation problem

2017-06-12 Thread ketmar via Digitalmars-d-learn
p.s.: while i understand the technical reason for second error message, it is still random and confusing.

Re: Weird template instantiation problem

2017-06-12 Thread ketmar via Digitalmars-d-learn
more funny compiler messages: alias xx = size_t function (int[]); struct S1(T, typeof(xx) X) {} void main() { S1!(int, defaultChooser!int) s; } Error: type uint function(int[]) is not an expression but: struct S2(T, typeof(defaultChooser!T)

Re: Weird template instantiation problem

2017-06-12 Thread Arafel via Digitalmars-d-learn
On 06/12/2017 05:31 PM, Arafel wrote: Hi, I've found a strange problem, and I'm not sure if it's a bug. To give a bit of background, I'm implementing a multi-threaded producer-consumer where the next work item to be picked depends not only on the "waiting queue", but also on what else is

Weird template instantiation problem

2017-06-12 Thread Arafel via Digitalmars-d-learn
Hi, I've found a strange problem, and I'm not sure if it's a bug. To give a bit of background, I'm implementing a multi-threaded producer-consumer where the next work item to be picked depends not only on the "waiting queue", but also on what else is being run (and potentially where) at the