Why does this template not have the desired result?

JS js.mdnq at gmail.com
Fri Jul 19 14:41:42 PDT 2013


On Friday, 19 July 2013 at 20:26:36 UTC, Gary Willoughby wrote:
> Why does this template not have the desired result? I honestly 
> though it would return true.
>
> import std.stdio;
>
> template inBounds(size_t size, T)
> {
> 	enum result = (size >= T.min && size <= T.max);
> }
>
> void main(string[] args)
> {
> 	writefln("%s", inBounds!(10, int).result); // false! eh?
> }

I ran into the same issue earlier... if (a > d + 1) would fail 
even though a = 0 and d + 1 = -1 (supposedly, said the 
debugger)...



More information about the Digitalmars-d-learn mailing list