This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
STL problem
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 17 May 2002 14:49:34 -0700
- Subject: STL problem
The STL that is in the gcc repository has (I'm looking at Apple's gcc3
project, but I assume this is the case in the real repository too since
it isn't marked 'APPLE LOCAL') ...
const charT* c_str () const
{ if (length () == 0) return ""; terminate (); return data (); }
This is fine except that is makes this class useless except for byte
oriented strings. Instead, it seems like it should be something like:
const charT* c_str () const
{
static const charT emptyString[1] = {0};
if (length () == 0) return emptyString; terminate (); return data ();
}
The advantage to this is that if I have the following (which is
commented out in <string>, interestingly):
typedef basic_string <wchar_t> wstring;
Then I can meaningfully call c_str() on it.
-tim