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

Re: "basic_string" problem in libstdc++


> 
> 
> It looks like basic_string is broken:
> 

Have you been able to pass "make check" on tstring?
I couldn't. And the 970929's patch on tstring.cc,
which is enclosed here, looks pretty much bogus to me.
I cannot find a matching basic_string constructor
for

  string is (ar, ar+sizeof(ar)/sizeof(ar[0]));

nor a matching replace memeber function for

  x.replace (find (x.begin (), x.end (), 'l'),
	     find (x.rbegin (), x.rend (), 'l').base (),
	     ar, ar+sizeof(ar)/sizeof(ar[0]));

Am I missing something?

Thanks.


H.J.
--
Index: tstring.cc
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libstdc++/tests/tstring.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.2
diff -u -r1.1.1.1 -r1.1.1.2
--- tstring.cc	1997/08/26 00:21:29	1.1.1.1
+++ tstring.cc	1997/10/01 19:56:05	1.1.1.2
@@ -14,8 +14,9 @@
 // You should have received a copy of the GNU General Public License
 // along with this library; see the file COPYING.  If not, write to the Free
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- 
+
 #include <string>
+#include <algorithm>
 #include <iostream.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -65,6 +66,10 @@
   assert(i == 20);
   assert(f == 20);
 
+  int ar[] = { 'H', 'e', 'l', 'l', 'o' };
+  string is (ar, ar+sizeof(ar)/sizeof(ar[0]));
+  cout << "is = " << is << endl;
+  assert (is == "Hello");
 }
 
 void cattest()
@@ -142,6 +147,13 @@
   x.replace (0, 1, 'j');
   cout << "x.replace (0, 1, 'j'); x = " << x << "\n";
   assert(x == "jello");
+
+  int ar[] = { 'H', 'e', 'l', 'l', 'o' };
+  x.replace (find (x.begin (), x.end (), 'l'),
+	     find (x.rbegin (), x.rend (), 'l').base (),
+	     ar, ar+sizeof(ar)/sizeof(ar[0]));
+  cout << "x = " << x << endl;
+  assert (x == "jeHelloo");
 }
 
 void iotest()


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