[Nfd-dev] size_t vs std::size_t

Junxiao Shi shijunxiao at email.arizona.edu
Tue Jul 22 01:10:02 PDT 2014


Dear folks

A question is raised in code review regarding whether we should use size_t
or std::size_t in our code.

According to answers in <
http://stackoverflow.com/questions/5813700/difference-between-size-t-and-stdsize-t
>:

* std::size_t is in C++ standard, defined in <cstddef> header
* size_t is from C standard, defined in <stddef.h> header
* C++ standard requires, if an implementation defines size_t, it must be
same as std::size_t
* all major compilers define both size_t and std::size_t in <cstddef>
* our code includes <cstddef>

Therefore, there is no functional difference between these two types.

My opinion is: we should use size_t because it's more concise.
To fully support C++ standard, we should also add "using std::size_t"
statement in common.hpp.

Yours, Junxiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20140722/dc0fb46b/attachment.html>


More information about the Nfd-dev mailing list