[PATCH] Add non-const overload of std::string::data()
Jonathan Wakely
jwakely@redhat.com
Wed Jul 13 14:59:00 GMT 2016
On 13/07/16 12:12 +0100, Jonathan Wakely wrote:
>Also fix confusion between pointer and _CharT*, so that allocators with
>fancy pointers work correctly.
>
>The _M_data() function returns pointer, but we were using it where
>_CharT* was required. This introduces a new _M_c_str() function which
>returns a _CharT* instead, and uses that for c_str() and both
>overloads of data().
>
>Most places using _M_data() can just use data() instead, as they only
>need a const _CharT*. A few need to use _M_c_str() to get _CharT* so
>they can write to it (they could use the new data() overload, except
>that it's not defined until C++17).
>
>Tested x86_64-linux, committed to trunk.
>
> * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] (_M_c_str):
> New function.
I forgot to add the new exports to the commit, new patch coming
shortly...
More information about the Libstdc++
mailing list