is size_t always unsigned?

后端 未结 6 1860
陌清茗
陌清茗 2020-12-01 07:07

As title: is size_t always unsigned, i.e. for size_t x, is x always >= 0 ?

6条回答
  •  被撕碎了的回忆
    2020-12-01 07:34

    Yes. It's usually defined as something like the following (on 32-bit systems):

    typedef unsigned int size_t;
    

    Reference:

    C++ Standard Section 18.1 defines size_t is in which is described in C Standard as .
    C Standard Section 4.1.5 defines size_t as an unsigned integral type of the result of the sizeof operator

提交回复
热议问题