static assert("nothing")

realhet real_het at hotmail.com
Tue May 31 08:51:45 UTC 2022


Hi,

In my framework I just found a dozen of compile time error 
handling like:

...else static assert("Invalid type");

This compiles without error. And it was useless for detecting 
errors because I forgot the first "false" or "0" parameter.

I think it is because of the weird case of "every string casted 
to bool is true".

There is an example in Phobos also:  
https://github.com/dlang/phobos/blob/master/std/uni/package.d
at line 8847: static assert("Unknown normalization form "~norm);

It is easy to make this mistake, but does static assert(string) 
has any meaningful use cases?


More information about the Digitalmars-d-learn mailing list