On Sat, Nov 18, 2006 at 12:23:39PM +0100, Georg Baum wrote:
> Am Samstag, 18. November 2006 10:55 schrieb Jean-Marc Lasgouttes:
> > >>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]>
> writes:
> >
> > Andre> I don't understand the difference.
> >
> > Easy: the new one works :)
> >
> > More precisely, the string is now a docstring and tricks with
> > null-terminated strings are not working anymore.
>
> For me the old version works, too (gcc 4.1.2). In theory the docstring vs.
> std::string does not make any difference here. std::basic_string is not
> required to terminate the string with 0 (but the recent gcc libstdc++
> does, see for example
> http://gcc.gnu.org/ml/gcc-patches/2004-01/msg01777.html, because c_str()
> is required to return a 0-terminated string). Fact is that
>
> str_.resize(3);
> str_[0] = '#';
> str_[1] = static_cast<char_type>('0' + n);
> str_[2] = '\0';
>
> is beyond the standard. If it would make sense at all resize(2) should be
> used.
Ah. You are right. Originally it was a plain character array, so I did
not think too hard about the terminating 0.
So Jean-Marc, could you please check whether
str_.resize(2);
str_[0] = '#';
str_[1] = static_cast<char_type>('0' + n);
works for you?
Andre'