In a framework that makes use of the std::int* types (such as std::int16_t) as well as the std::int_fast* types (such as std::int_fast16_t) there could be general rules where one could be better than the other. I am going to refer to std::int* types as "exact" types and std::int_fast* types as "fast" types for simplicity of this post
As an example, it generally could be best to use exact types for array elements because it would be expected that they use less bytes and so there is more opportunity for caching improvement. As another example, when elements are read from that array they can be converted to the fast type for the purpose of doing arithmetic
void foo() {
std::array arr {};
// ...
std::int_fast16_t e = arr[index];
}
What is less obvious is which type is more appropriate for key types of std::set, std::unordered_set , or the related map types. Would it make sense to assume the container's internal storage generally benefits more from compactness of exact types like the array case?