Jump to content
  • Advertisement
Sign in to follow this  
TEUTON

std::size_t compared to size_t

This topic is 4382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!