This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add non-const overload of std::string::data()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]