This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add missing clear() method to bastring.h in 2.96.x
- To: gcc-patches at gcc dot gnu dot org
- Subject: Add missing clear() method to bastring.h in 2.96.x
- From: Jean-Francois Panisset <panisset at discreet dot com>
- Date: Sat, 10 Jun 2000 18:34:14 -0400
- cc: panisset at discreet dot com
Apparently, libstdc++-v3 will provide a compliant implementation
of the standard C++ library. In the meantime, for 2.9x releases,
I would like to suggest the following patch to
include/g++-3/std/bastring.h:
*** bastring.h.orig Sat Jun 10 17:44:06 2000
--- bastring.h Sat Jun 10 17:45:43 2000
***************
*** 346,351 ****
--- 346,353 ----
{ resize (n, eos ()); }
void reserve (size_type) { }
+ void clear() { erase(begin(), end()); }
+
size_type copy (charT* s, size_type n, size_type pos = 0) const;
size_type find (const basic_string& str, size_type pos = 0) const
which adds the clear() method to the basic_string class, as per
section 21.3.3, "basic_string capacity" of the ANSI C++ standard.
This is probably not an optimal implementation, but it seems to work,
and is based on the suggested implementation in the standard.
JF
Jean-Francois Panisset panisset@discreet.com
Software Engineer
Discreet Logic