I've noticed that my C++ programs compile fine whether I use ::size_t or std::size_t. I can use them interchangeably with no issues at all, so it seems like one of them is a typedef for the other.
As an example, consider the following code which uses the global size_t (this is the whole file, no usings and other stuff):
#include <iostream>
int main() {
::size_t x = 100;
std::cout << x << std::endl;
}
The next code uses the size_t in std:
#include <iostream>
int main() {
std::size_t x = 100;
std::cout << x << std::endl;
}
Both compile fine and outputs 100 as expected.
I was under the impression that everything in the standard library is put in namespace std, but clearly this isn't the case. Why is this so?
Note: the same goes for ptrdiff_t, intN_t and uintN_t too.