This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

Re: basic_string<> - patch


On Tue, 8 Jun 1999, Benjamin Kosnik wrote:

> 
> 
> > 1999-06-08  Ryszard Kabatek <kabatek@chemie.uni-halle.de>
> > 
> > 	* bits/basic_string.h:
> > 	  basic_string<>::_S_copy_chars<> - add specializations for 
> > 	  _CharT*, iterator and const_iterator.
> 
> Can you please send along a code snippet demonstrating the problem /
> reason for this patch? I'm assuming it has to do with string invariants
> and correct conversion of string arguments, but it's not immediately
> clear.

It is a bit dificult. 
In the template version of _S_copy_chars<> I added
printf("template\n"); 
and I run a simple test:

int main()
{
  const char* p1 = "lolo";
  string s1(p1, p1+2);   // const _CharT*
  printf("---\n");
  char* p2 = "lolo";
  string s2(p2, p2+2);   // _CharT*
} 
If I run the sample I get:
--- 
template

So I added the specialization for _CharT*.
Than I got only 
---

But if I try:

int main()
{
  string s1("lolo");
  const string& str = s1;
  string s2(str.begin(), str.end()); // const_iterator
  printf("---\n");
  str s3(s1.begin(), s1.end()); // iterator
}

I got:
template
---
template

Than I added the specializations for iterator and const_iterator
and I added in all versions of _S_copy_chars a printf function
for the next tests.

So we REALLY ned the specializations.

BTW. _M_check and _M_fold both returns iterator, so currently
in the most casses the SLOW template version of _S_copy_chars is called. 


Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 (2466) Fax. +49 3461 46 2129


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