Fastest way to check using if identifier has already been defined, using static if or similar?

drathier forum.dlang.org at fi.fo
Wed Jun 3 09:03:22 UTC 2020


I'm generating some code. Some of the generated types need to be 
overridden, so I define them manually at the top of the generated 
file. Then I need to guard against redefining the identifier 
(type/value/function) later on, in the generated code.

I'm currently using `static if (!__traits(compiles, thingy)) {` 
to avoid redefining things twice.

Of course the proper fix is to not generate code for the 
identifiers which are already manually defined, and not generate 
any `static if`s at all, but until then, is there a faster way 
than `static if (__traits(compiles, ...` to check if a 
type/value/function has already been defined?


More information about the Digitalmars-d-learn mailing list