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]

Add missing clear() method to bastring.h in 2.96.x



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 

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