std :: string的默认容量? [英] Default capacity of std::string?

查看:702
本文介绍了std :: string的默认容量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用默认构造函数创建std :: string时,是否在堆上分配了任何内存?我希望答案不依赖于实现和标准化。请考虑以下内容:

  std :: string myString;不幸的是,根据N3290,答案是否定的。       / p> 

表63 Page 643说:




  • 一个可以复制的非空指针,可以添加0。

  • size() 0

  • capacity()未指定的值


$ b b

该表与C ++ 03相同。


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 is standardized. Consider the following:

std::string myString;

解决方案

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.

这篇关于std :: string的默认容量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆