Re: Function template advice

2017-01-18 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:39:02 UTC, Ali Çehreli wrote: On 01/18/2017 02:02 PM, Jordan Wilson wrote: [...] Yes, can be better with something similar to the following: struct Foo { string bar; } string value(U : Foo)(U u) { return u.bar; } string value(U : string)(U u) {

Re: Function template advice

2017-01-18 Thread Ali Çehreli via Digitalmars-d-learn
On 01/18/2017 02:02 PM, Jordan Wilson wrote: I have a simple comparison function: struct Foo { string bar; } auto sameGroup(T,S) (T a, S b) { static assert (is(T == string) || is(T == Foo)); static assert (is(S == string) || is(S == Foo)); string aStr; string bStr;

Function template advice

2017-01-18 Thread Jordan Wilson via Digitalmars-d-learn
I have a simple comparison function: struct Foo { string bar; } auto sameGroup(T,S) (T a, S b) { static assert (is(T == string) || is(T == Foo)); static assert (is(S == string) || is(S == Foo)); string aStr; string bStr; static if (is(T == string)){ aStr = a;