Is this a bug? `static if` fails silently.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 4 01:07:09 PST 2014


On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:
> struct Test(T)
> {
> 	static if (is(typeof(T) == int))
> 	{
> 		pragma(msg, "test");
> 		
> 		this(T t)
> 		{
> 			this.t = t;
> 		}
> 	}
> }
>
> void main()
> {
>         //Nothing is printed
> 	Test!int t;
> }
>
> Didn't this code used to failed at the point of `typeof(T)`? 
> Has this changed since previous releases?

It is not static if, it is is. Is is defined as false for invalid 
types.


More information about the Digitalmars-d mailing list