A code example that shows why I don't like warnings
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Sat Oct 19 16:14:20 UTC 2019
On Friday, 18 October 2019 at 18:22:33 UTC, Adam D. Ruppe wrote:
> On Friday, 18 October 2019 at 18:19:55 UTC, Alexandru Ermicioi
> wrote:
>> You can define a bool enum in the body of static if (inside
>> foreach) and then wrap default return statement with static
>> if that checks if that enum was defined. If it wasn't then
>> return "default".
>
> oh that's not horrible and it works too. But still I don't love
> it :)
>
> BTW as of today my whole lib will compile with warnings
> including when exercising the more complicated templates!
Yeah it is not ideal. This trick can also shield you in case if
multiple elements from static foreach matches inner static if,
just by adding a check to it if this enum was defined earlier.
Also beware of code blocks for foreach or inner static if, since
it will limit enum declaration to that block and wont be
available to static if defined outside of foreach (the one for
default return).
More information about the Digitalmars-d
mailing list