Static asserts within unittest block
bearophile
bearophileHUGS at lycos.com
Tue Mar 29 11:14:54 PDT 2011
Jonathan M Davis:
> If a static assert is in a unit test block it's to verify that something
> works. You don't necessarily want it in normal code. For instance, what if the
> static assert is verifying something about a templated type or function?
> Having that static assert in the normal code would mean that that particular
> instantiation of the function would always be in the code, whereas putting the
> static assert in the unit test would only result in that instantiation during
> unit tests (unless you actually instantiated it in your code).
Right. Some static asserts may cause/need the instantiation of a template, that burns both compile time and sometimes some space in the not so well stripped binary. So putting those static asserts just inside the unittests is good.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list