[Nfd-dev] size_t vs std::size_t
Alex Afanasyev
alexander.afanasyev at UCLA.EDU
Tue Jul 22 10:33:09 PDT 2014
I have no objections of using size_t in most cases. The place from which this question arises is boost::asio. Boost.Asio documentation specify "WriteHandle" to use std::size_t, so I don't see a big contradiction of using std::size_t in boost-asio related things, while using size_t for other places.
---
Alex
On Jul 22, 2014, at 10:16 AM, Davide Pesavento <davide.pesavento at lip6.fr> wrote:
> On Tue, Jul 22, 2014 at 10:10 AM, Junxiao Shi
> <shijunxiao at email.arizona.edu> wrote:
>> 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>
>
> Where? I see only <stddef.h> in ndn-cxx's common.hpp (which is
> included by NFD's common.hpp). Should we switch to the C++ variant?
>
>>
>> Therefore, there is no functional difference between these two types.
>>
>> My opinion is: we should use size_t because it's more concise.
>
> +1
>
>> To fully support C++ standard, we should also add "using std::size_t"
>> statement in common.hpp.
>
> Yes, but only if we change ndn-cxx to include <cstddef> rather than <stddef.h>.
>
> Thanks,
> Davide
More information about the Nfd-dev
mailing list