|
|
|
|
|
by xsmasher
4658 days ago
|
|
I avoid them like a plague, except in specific situations where I need the extra range or need to save the bytes. I expect my reasons will be unpopular. Suppose you have an object with a interface like object.setValue(7). You'd like to assert that people are sending you valid data, but if the type is uint then you can't do that. if the type is int, then you can assert(value>0, "Value must be greater than zero"). Now if anyone calls setValue(-1) you'll get an assertion that would have been skipped before. I feel that pedants and more experienced C++ programmers will tell me I am sloppy or should be getting warnings on setValue(-1) but I've been burned before. My life is easier when I avoid unsigned types. The behavior of int delta = unit1 - unit2 is also annoying. Not unexpected if you're paying attention, just annoying. I might use them more if underflow / overflow caused an exception instead of undefined behavior. |
|