Default capacity of std::string?

前端 未结 5 1385
灰色年华
灰色年华 2020-12-20 14:22

When I create a std::string using the default constructor, is ANY memory allocated on the heap? I\'m hoping the answer does not depend on the implementation and

5条回答
  •  感情败类
    2020-12-20 15:11

    Unfortunately, the answer is no according to N3290.

    Table 63 Page 643 says:

    • data() a non-null pointer that is copyable and can have 0 added to it
    • size() 0
    • capacity() an unspecified value

    The table is identical for C++03.

提交回复
热议问题