Sign in to follow this  
TEUTON

std::size_t compared to size_t

Recommended Posts

I just started reading C++ Templates: The Complete Guide By David Vandevoorde, Nicolai M. Josuttis In the beginning chapter author says
Quote:
This is not a book about the C++ standard library, but we do make use of that library in some of our examples. In general, we use the C++-specific headers (for example, <iostream> rather than <stdio.h>). The exception is <stddef.h>. We use it instead of <cstddef> and therefore do not qualify size_t and ptrdiff_t with the std:: prefix because this is still more portable and there is no advantage in using std::size_t instead of size_t.
I can't understand why author say that size_t is more portable than std::size_t and why std::size_t is not having any advantage over size_t.

Share this post


Link to post
Share on other sites
Quote:
Original post by TEUTON
I can't understand why author say that size_t is more portable than std::size_t and why std::size_t is not having any advantage over size_t.

Visual C++ 6.0 did not have a form of size_t in the std namespace, and it was one of the most commonly used compilers in its time. Including <cstddef> and trying to access std::size_t would only result in error. This is no longer true, and you should generally prefer using std::size_t.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this