std::size_t compared to size_t

Started by
1 comment, last by Polymorphic OOP 17 years, 9 months ago
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.
Advertisement
Because the book is from 2002 maybe? So likely written in 2001.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

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.

This topic is closed to new replies.

Advertisement