This is the mail archive of the gcc@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]

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


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