Is std::string
reference-counted when using gcc 4 with -std=c++0x
or -std=c++11
?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
C++11 added specific language forbidding
std::string
from being reference counted. So if it is, then it's a pretty significant failing in GCC's C++11 standard library.Looking at libstdc++ documentation I find (see the link for more info):
A string looks like this:
So, yes it is ref counted. Also, from the discussion here:
So, it seems there are plans to change it to be conforming (I don't know how the progress is going though).
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 replacedstd::string
is because of ABI compatibility. There is an SO question about it here.Adding some useful information that post-dates this question.
std::string
will no longer be reference-counted with the release of GCC 5, to address this C++11 requirement.From https://gcc.gnu.org/gcc-5/changes.html