Is `size_t` always an alias for vector <int> :: size_type` or any other type of container?
Let me make a simple example:
Formula 1:
std::vector<int> vec;
// add 10E11 elements
for(std::size_t n = 0; n < vec.size(); ++n)
// ...
Formula 2:
std::vector<int> vec;
// add 10E11 elements
for(std::vector<int>::size_type n = 0; n < vec.size(); ++n)
// ...
Naturally, unsigned intor any unacceptable data types do not work here, and we must compile x64. My question is: is there any case where the first formulation can lead to problems, or can we safely always write it in this much shorter notation? I am also interested in similar settings if they are trivial to cover (x86, any other container, other applications size_type).
+4
3 answers