What to do with size_t and std :: size_t?

Just reading:

Does "std :: size_t" make sense in C ++?

I understand that use is ::size_tnot up to standard (although supported by my compiler) when you are #include <cstddef>. I want to conform to the standard, but I do not want to add std::to all mine size_t. So what is the more familiar / popular way to handle this:

  • to write using std::size_t;?
  • turn on <stddef.h>?
  • just rely on compiler support?
  • something else?
+6
source share
2 answers

You must specify it using the use directive.

using std::size_t;

, , .

stddef.h , , , , "", . stddef.h - , .

use, , , . , , , size_t.

, . 10 ++ 1998 , ++. , , , - stddef.h, .

"std::" , using, . , , "" , . , , , , , , size_t.

, FAQ ++ ( 27.5) , , .

, " std" , , size_t . .

, tuple_cat (), , , , . github , , , :

A) "size_t" AND "stddef.h" language:c++
B) "std::size_t" AND "<cstddef>" language:c++
C) "size_t" AND "<cstddef>" AND NOT "std::size_t" language:c++
D) "size_t" AND "<cstddef>" AND "using namespace std" AND NOT "std::size_t" language:c++
E) "size_t" AND "<cstddef>" AND "using std::size_t" language:c++

:

  • A) 974 239 ( stddef.h)
  • B) 1,230,021 ( cstddef std:: pre)
  • C) 469 721 ( cstddef, )
  • D) 32 539 (cstddef , " std", !)
  • E) 27 080 (, , " std:: size_t" )

, , , , , , , , . , "std::" size_t (B), "stddef.h" (A). , (D) , , /, size_t , (C).

, " ", "std::" . , "stddef.h" , - using.

+5

, / :

, :

GitHub "std::size_t" ++: 4 650 049 .
GitHub "size_t" ++: 24 835 033 .

"#include <stddef.h>" 1,051,142 , "#include <cstddef>" 2,099,971. "using std::size_t;" 50 057 .

, .

+3

Source: https://habr.com/ru/post/1015743/


All Articles