Patrick Dubroy @dubroy.com · Nov 11

Somewhat surprising (to me) advice in Google's C++ style guide: "Try to avoid unsigned types (except for representing bitfields or modular arithmetic). Do not use an unsigned type merely to assert that a variable is non-negative." Example of a possible bug: abseil.io/tips/227 (via @wingolog.org)

16 likes 1 replies

?

Replies

Patrick Dubroy · Nov 11

This seems like such a tiny thing but I always thought using unsigned ints for sizes was the "correct" thing to do, so I do it even though it's generally a little annoying (b/c casts, fretting about whether temp vars should be unsigned or signed, etc.)