std :: ostringstream缓冲区的最大大小是多少? [英] What is the maximum size of std::ostringstream buffer?
问题描述
是否根据可用的动态分配内存量分配了大小?当达到此限制时会发生什么情况,是否抛出异常或将其覆盖到内存的其他部分?还是默默地停止写缓冲区?
Is the size allotted based on amount of dynamically allotted memory available? what happens when we reach this limit is there an exception thrown or it overwrites to some other part of memory? Or it silently stops writing to buffer?
推荐答案
std :: stringstream $的缓冲区c $ c>对象是
std :: string
对象的包装。因此,最大大小为 std :: string :: max_size()
。当流无法进一步分配时,扩展到该流的缓冲区将引发异常。响应是在其流状态下打开 std :: ios_base :: badit
。除非清除了流状态并且至少部分清空了缓冲区,否则尝试写通过将不会有任何作用。
The buffer of a std::stringstream
object is a wrapper around a std::string
object. As such, the maximum size is std::string::max_size()
. When the stream cannot allocate further, an exception will be thrown by the buffer which is probagated to the stream. The response is to turn on std::ios_base::badit
in its stream state. Attempting to write pass this point will do nothing unless the stream state is cleared and the buffer is at least partially emptied.
这篇关于std :: ostringstream缓冲区的最大大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!