unsigned < 0

Iain Buclaw ibuclaw at ubuntu.com
Fri Feb 11 11:17:52 PST 2011


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> > To avoid troubles in generic code you need a little workaround:
> > if (__traits(isUnsigned, x) || x >= 0) { ...
> That's not good enough yet. The first part of the test needs to be done in a
static if.
> Bye,
> bearophile

You also need to watch out for code like this too:
if (T.min < 0) { ...
As that could possibly trigger off unsigned < 0 warnings too.

Regards
Iain


More information about the Digitalmars-d mailing list