C++ guys hate static_if?

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Mar 14 10:09:26 PDT 2013


On 3/14/13, bearophile <bearophileHUGS at lycos.com> wrote:
> This is an invalid argument. You can say the same thing for many
> (most?) tests done by the compiler. Unit tests can't be sure to
> verify all code paths inside a function or template.

No, it must do exactly that. If you have so many paths that you can't
reasonably test all paths then your template or function is too
complicated to begin with. The benefit here of D over C++ is that unit
testing is cheap and doesn't require external libraries.

You use template constraints to limit the code paths, and you use
unittests to verify semantics. Then there's also static assert(0).


More information about the Digitalmars-d mailing list