c++ - GCC 的 "vstring"是什么?

标签 c++ gcc

我阅读了一些 GCC 错误报告,那里的人在谈论“vstring”。上网搜索发现http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.2/vstring_8h.html .

有人可以详细说明它的用途和用途吗?为什么要使用它而不是 std::string?

最佳答案

GCC 的 vstring是一个通用的字符串类,在 GCC 4.1 的 libstdc++ 中引入实现。

兼容std::basic_string ,以及这些额外的细节:

  • 提供了两个基类:
    • 默认的避免引用计数,并针对短字符串进行了优化;
    • 替代方案仍然使用它(即引用​​计数),同时在一些低级领域(例如对齐)进行了改进。见 vstring_fwd.h一些有用的 typedef。
  • 重写了各种算法(例如替换),简化了代码并添加了简单的优化。
  • DR 431 的选项 3 适用于两个可用的基础,从而改进了对有状态分配器的支持。

DR431 是 Library Working Group Defect Report 431 ,选项 3 看起来像是为类实现更好的分配器支持,以允许更好的交换和其他与分配器相关的操作。

基本细节来自GCC 4.1's release notes ,在运行时库部分下。

编辑:

看起来这个扩展的最初目的是为 C++11 std::string 提供基础。执行。 Paolo Carlini,GCC/libstdc++ 贡献者,在此 GCC Bug Report 中发表评论那<ext/vstring.h>包含下一个 std::string 的非引用计数实验版本. 2012 年 4 月 12 日的评论:

What we tried to explain is that this sort of issue is well known and, more or less, affects any reference counted implementation... That is not the case when reference counting is not used and indeed it will not be used (per the new C++11 Standard) in a new implementation of std::string which we are currently showcasing as <ext/vstring.h>...

关于c++ - GCC 的 "vstring"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10463851/

相关文章:

C++11:GCC 4.8 静态 thread_local std::unique_ptr 未定义引用

c++ - 在 C++ 中使用 Media Foundation 和 Windows 8 捕获问题

c - 如何在 Linux 中抑制 -Werror=pointer-to-int-cast 和 -Werror=address 类型的错误

c++ - 为什么 C 和 C++ 编译器在从未强制执行时允许函数签名中的数组长度?

c++ - 附加到 Qt Creator 中正在运行的进程后如何查看控制台输出?

linux - 将 VC++ SetWaitableTimer 移植到 gcc

c - 如何在 linux 中使用 windows sockets 编译程序?

android - 获取错误 ld.exe : error: cannot find -lgnuSTL_shared in ndk on compiling tbb source files

c++ - 返回引用时的 std::vector::emplace_back 错误 (C++17)

C++重新定义