什么是GCC的“vstring”? [英] What is GCC's "vstring"?

查看:497
本文介绍了什么是GCC的“vstring”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些GCC bugreport,有人在说vstring。搜索WEB我注意到了 http://gcc.gnu.org/onlinedocs /libstdc++/libstdc++-html-USERS-4.2/vstring_8h.html



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

解决方案

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



code> std :: basic_string ,包含以下附加详细信息:






    • 默认值避免引用计数,并针对短字符串进行优化;

    • 仍在使用它(引用计数),同时在几个低级区域(例如,对齐)中提高。 c>


    • 各种算法已被重写,请参阅 vstring_fwd.h

    • DR 431的选项3针对两个可用基准实施,因此改进了对状态分配器的支持。



    DR431是库工作组缺陷报告431 ,选项3看起来像为类实现更好的分配器支持以允许更好的交换和其他与分配器相关的操作。



    基本详情请参阅运行时库部分下的 GCC 4.1发行说明。 / p>

    编辑:



    看起来这个扩展的最初目的是为C + +11 std :: string 实现。 GCC / libstdc ++参与者Paolo Carlini在此 GCC错误报告中评论了< ext / vstring.h> 包含下一个 std :: string 的非引用计数实验版本。 2012年4月12日的评论:


    我们试图解释的是,这种问题是众所周知的,更多或
    减少,影响任何引用计数的实现...
    不使用引用计数,确实不会是
    (在新的C ++ 11标准中)在 std :: string 的新实现中使用
    我们目前显示为< ext / vstring.h>
    ...



    I read some GCC bugreport and people there were talking about "vstring". Searching the WEB I came to notice http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.2/vstring_8h.html .

    Can someone please elaborate on what it is useful and used for? Why use it instead of std::string?

    解决方案

    GCC's vstring is a versatile string class, which was introduced in GCC 4.1's libstdc++ implementation.

    It is compatible with std::basic_string, with these additional details:

    • Two base classes are provided:
      • the default one avoids reference counting and is optimized for short strings;
      • the alternate one, still uses it (reference counting, that is) while improving in a few low level areas (e.g., alignment). See vstring_fwd.h for some useful typedefs.
    • Various algorithms have been rewritten (e.g., replace), the code streamlined and simple optimizations added.
    • Option 3 of DR 431 is implemented for both available bases, thus improving the support for stateful allocators.

    DR431 is Library Working Group Defect Report 431, with option 3 looking like implementing better allocator support for the class to allow better swapping and other allocator-related operations.

    The basic details are from GCC 4.1's release notes, under the Runtime Library section.

    edit:

    It looks as though the original purpose of this extension was to provide a basis for a C++11 std::string implementation. Paolo Carlini, a GCC/libstdc++ contributor, comments in this GCC Bug Report that <ext/vstring.h> contains a non-reference counted experimental version of the next std::string. Comment dated April 12, 2012:

    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>...

    这篇关于什么是GCC的“vstring”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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