是std :: string引用计数在GCC 4.x / C ++ 11? [英] Is std::string refcounted in GCC 4.x / C++11?
问题描述
当使用gcc 4和 -std = c ++ 0x
时, std :: string
-std = c ++ 11
?
Is std::string
reference-counted when using gcc 4 with -std=c++0x
or -std=c++11
?
推荐答案
href =http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01016_source.html#l00114> libstdc ++文档我找到了(更多信息,请参阅链接):
Looking at libstdc++ documentation I find (see the link for more info):
字符串如下所示:
[_Rep]
_M_length
[basic_string<char>] _M_capacity
_M_dataplus _M_refcount
_M_p ----------------> unnamed array of char_type
因此,此外,从此处的讨论:
So, yes it is ref counted. Also, from the discussion here:
是的,std :: string将在某一时刻进行非引用计数,
,但作为非引用计数字符串在C ++ 98中也是有效的,一个
选项将切换到
-std = c ++ 98和-std = c ++ 11模式的非ref计数字符串。我不是说这会发生什么,但它可以是。
Yes, std::string will be made non-reference counting at some point, but as a non-reference-counted string is valid in C++98 as well, one option would be to switch to a non-ref-counted string for both -std=c++98 and -std=c++11 modes. I'm not saying that's what will happen, but it could be.
所以,似乎有计划将其更改为
So, it seems there are plans to change it to be conforming (I don't know how the progress is going though).
更新
正如emsr在评论中指出的,目前有一个非引用计数扩展名为 vstring.h
,似乎是它没有替换 std :: string
是因为ABI兼容性。有一个SO问题这里。
Update
As emsr points out in the comments, there is currently a non-reference counted extension called vstring.h
, and it seems the only reason it hasn't replaced std::string
is because of ABI compatibility. There is an SO question about it here.
这篇关于是std :: string引用计数在GCC 4.x / C ++ 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!