gpt4 book ai didi

c++ - std::ostringstream 的字符串的默认值?

转载 作者:行者123 更新时间:2023-11-28 01:19:48 26 4
gpt4 key购买 nike

我想知道 std::ostringstream 是否总是用空字符串初始化。

std::ostringstream ss;

bool isEmpty = ss.str().empty();

isEmpty 会一直为真吗?

最佳答案

阅读docs .

default (1) 
explicit ostringstream (ios_base::openmode which = ios_base::out);

(1) empty constructor (default constructor) Constructs an ostringstream object with an empty sequence as content. Internally, its ostream base constructor is passed a pointer to a stringbuf object constructed with an argument based on which.

所以,是的。

关于c++ - std::ostringstream 的字符串的默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57016916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com