Static assert triggered in struct constructor that shouldn't be called

Adam D. Ruppe destructionator at gmail.com
Sun May 24 21:44:18 UTC 2020


On Sunday, 24 May 2020 at 21:34:53 UTC, jmh530 wrote:
> The following code results in the static assert in the 
> constructor being triggered, even though I would have thought 
> no constructor would have been called.

static assert is triggered when the code is *compiled*, whether 
it is actually run or not.

So as long s the function exists, its static asserts must all 
pass before it even gets to the runtime decision of if it is 
actually called or no.


More information about the Digitalmars-d-learn mailing list