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

前端 未结 8 565
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:13

    Section 17.4.1.2 of the C++ standard, paragraph 4, states that:

    "In the C++ Standard Library, however, the declarations and definitions (except for names which are defined as macros in C) are within namespace scope (3.3.5) of the namespace std."

    This includes items found in headers of the pattern cname, including cstddef, which defines size_t.

    So std::size_t is in fact correct.

提交回复
热议问题