std::字符串串联操作
std::string concatenation operations
实际上我想知道std::string
operator+=
和append
方法之间有什么不同。乍一看,他们解决了同样的问题。
在我的例子中,结果字符串是从不同的字符串编译而来的,这些函数中的哪一个更有效或更合适?还是应该使用std::stringstream
?
在我看来,std::string
与std::vector
有很多共同点(capacity
、reserve
和其他方法(,可以在追加操作期间重新分配。
好吧,标准说:
constexpr basic_string& operator+=(const basic_string& str);
效果:等效于:
return append(str);
所以我想说他们完成了同样的事情。
相关文章:
- 重载操作程序时出错>>用于类中的字符串 memebr
- 对字符串进行位操作
- 字符串操作 - 字符计数
- 在 c++ 中对字符串进行操作的关系运算符无法按预期工作
- 字符串操作主题消息
- std::字符串串联操作
- 在MySql中使用字符串操作函数有什么问题
- 如何在没有外部库的情况下使用C++03约束执行基于正则表达式的字符串操作
- 使用来自串行端口的字符串数据来操作振镜扫描仪在更高的速度下会出错
- 如何使用 Win32 WCHAR 执行字符串操作
- C 库中是否有任何功能将字符串转换为算术操作
- 如何将字符 a= '+'(或字符串 []) 变成实际操作?
- UTF-8字符串上的位XOR操作可提供非UTF-8输出
- 一个用于操作字符串以在vba中使用的c++dll
- 操作字符串的函数 ( "abcdef" -> "faebdc" )
- 操作字符串c++
- c++:通过函数使用指针操作字符串
- 通过对dll的标准调用操作字符串的问题
- 如何操作字符串小写并存储在同一变量中
- 使用fork() c++在共享内存中操作字符串