Does “std::size_t” make sense in C++?

前端 未结 8 608
Happy的楠姐
Happy的楠姐 2020-11-29 23:28

In some code I\'ve inherited, I see frequent use of size_t with the std namespace qualifier. For example:

std::size_t n = sizeof(          


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 00:08

    There seems to be confusion among the stackoverflow crowd concerning this

    ::size_t is defined in the backward compatibility header stddef.h . It's been part of ANSI/ISO C and ISO C++ since their very beginning. Every C++ implementation has to ship with stddef.h (compatibility) and cstddef where only the latter defines std::size_t and not necessarily ::size_t. See Annex D of the C++ Standard.

提交回复
热议问题