https://github.com/lefticus/cppbestpractices/blob/master/03-Style.md#use-the-correct-integer-type-for-standard-library-features
good rules to follow, but you might like to add a remark about computing the difference between two sizes, because even when using auto you might get unexpected behaviour, ie. value underrun:
std::size_t a=3, b = 5;
auto c = a-b;
c is now some huge number, because c is still unsigned, and you don't get a warning. Also worth noting is that because std::size_t is generally defined as the largest unsigned integer type on a system, generally there is no signed type that will hold all values of a std::size_t. Thus the only safe way of computing the difference requires that you compare b<=a before you compute the difference and take appropriate action if b>a.
https://github.com/lefticus/cppbestpractices/blob/master/03-Style.md#use-the-correct-integer-type-for-standard-library-features
good rules to follow, but you might like to add a remark about computing the difference between two sizes, because even when using auto you might get unexpected behaviour, ie. value underrun:
cis now some huge number, becausecis still unsigned, and you don't get a warning. Also worth noting is that becausestd::size_tis generally defined as the largest unsigned integer type on a system, generally there is no signed type that will hold all values of astd::size_t. Thus the only safe way of computing the difference requires that you compareb<=abefore you compute the difference and take appropriate action ifb>a.