Re: Template condition evaluation (shortcircuit)

2018-03-21 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 21, 2018 at 05:42:34PM +, rumbu via Digitalmars-d-learn wrote: > I tried to define a template: > > enum isFoo(alias T) = > T.stringof.length >= 3 && T.stringof[0..3] == "abc"; > > int i; > pragma(msg, isFoo!i); > > Error: string slice [0 .. 3] is out of bounds > Error:

Template condition evaluation (shortcircuit)

2018-03-21 Thread rumbu via Digitalmars-d-learn
I tried to define a template: enum isFoo(alias T) = T.stringof.length >= 3 && T.stringof[0..3] == "abc"; int i; pragma(msg, isFoo!i); Error: string slice [0 .. 3] is out of bounds Error: template object.__equals cannot deduce function from argument types !()(string, string), candidates