I am working with Visual Studio 2017 Community Edition. It allows me to use both size_t
and std::size_t
without the appropriate includes. It appears to work with most of the std library. I assume it is because parts of the library itself use it. For instance one example that I found led to this behave was with vector
.
#include <vector>
#include <iostream>
int main()
{
size_t a = 42;
std::size_t b = 0;
std::cout << a << b;
std::cin.ignore();
}
Presumably this is because the size()
function returns an std::size_t
. Is this just a header dependency and I can avoid it with the proper include? That still doesn't explain why I can call it with the namespace scope.
(I'm not using using namespace std
.)
This question implies that not all headers in the std library should have the definition.