c++ – Why Microsoft so persistent in use size_t instead of std::size_t?


During the code review, the reviewer was very persistent in using std::size_t instead of size_t (see the comment under the code review post:

You’re still misspelling std::size_t. It’s not portable to assume that the standard library will define global-namespace equivalents of std-namespace identifiers (it’s allowed to, but not required to).

I see that size_t and std::size_tare both the same (at least to some degree).

If so, why Microsoft not only treats size_t as a build-in type (Which way Visual Studio 2022 compiles size_t without any include files? and Which C++ compilers automatically define size_t without requiring a header include?), but still suggests it as the default type for for loop code snippet in VS2022?

for (size_t i = 0; i < length; i++)
{
}

I know that I can easily edit the code snippet, but why Microsoft so persistently pushes size_t instead of std::size_t?

What is so important in size_t to Microsoft that is adherent to this type instead of standard one? Just to make code shorter, for legacy matters or there is some other reason?

Leave a Reply

Your email address will not be published. Required fields are marked *