Re: Passing struct and struct[] into a template

2015-07-23 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 04:29:26 UTC, Taylor Gronka wrote: Hi, I have a template function, and I want it to do something if the input variable is a list of structs, and something else if the input is a struct. [...] Take a look at this thread, the poster had the same question: http:/

Re: Passing struct and struct[] into a template

2015-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 04:29:23 Taylor Gronka via Digitalmars-d-learn wrote: > I have a template function, and I want it to do something if the > input variable is a list of structs, and something else if the > input is a struct. If you want a template to be different for different types, th

Re: Passing struct and struct[] into a template

2015-07-21 Thread Taylor Gronka via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 05:02:59 UTC, Timon Gehr wrote: template Uks(T){ T query(string q){ T result; static if(is(T==S[],S)){ ulong test=result.length; // append S newResult; result~=newResult; }else{ /

Re: Passing struct and struct[] into a template

2015-07-21 Thread Timon Gehr via Digitalmars-d-learn
On 07/22/2015 06:29 AM, Taylor Gronka wrote: Hi, I have a template function, and I want it to do something if the input variable is a list of structs, and something else if the input is a struct. 1) What's the best way to test this? I suppose I can call __traits(identifier, results) and look at

Passing struct and struct[] into a template

2015-07-21 Thread Taylor Gronka via Digitalmars-d-learn
Hi, I have a template function, and I want it to do something if the input variable is a list of structs, and something else if the input is a struct. 1) What's the best way to test this? I suppose I can call __traits(identifier, results) and look at the last two characters. 2) If `T` is a l