RE:Re: [CINT] [Fwd: [ROOT] string streams f

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Sun Jan 20 2002 - 02:41:24 MET


Hello Jiri,

>root [0] ostrstream buf; buf << 1 << ends;
>root [1] buf.str()
>(const basic_ostringstream<char,char_traits<char>,allocator<char>
>>::__string_type)275332816
>
>The return type of ostrstream.str() is different from how it works on
>root compiled with gcc-2.95. It used to return char* which is
>consistent with the docs at
>http://darbujan.fzu.cz/cgi-bin/info2www?(iostream-295)Strings
>Returning this type is what ostringstream should do I believe.

As I look into ANSI/ISO C++ standard, it says

         basic_string<charT,traits,Allocator> str() const;
         void    str(const basic_string<charT,traits,Allocator>& s);

And basic_ostringstream<char,char_traits<char>,allocator<char>::__string_type
is defined as basic_string<char,char_traits<char>,allocator<char> > which
is typedefed as string.  So, Cint with gcc3 behaves as it supposed to be.
In fact, I simply mirror what is defined in the standard header file and
I can not do much in this regard.


>Second try:
>Including headers results in the following error
>root [0] #include <string>
>root [1] #include <strstream>
>root [2] ostrstream buf; buf << 1 << ends;
>root [3] buf.str()
>Internal error: template function call G__ateval failed FILE: LINE:0
>(const basic_ostringstream<char,char_traits<char>,allocator<char>
>>::__string_type)276003640
>*** Interpreter error recovered ***

This is peculiar. Same thing works on my machine. 
It looks like evaluation of buf.str() is performed just fine. Problem 
occurs when Cint tries to print it out with G__ateval function template.
In fact, G__ateval function template should not be used because 
specialized version is defined in <string>.  Let me investigate.


>I tried also the ostringstream class

I simply typedef ostringstream and ostrstream to be identical type.
So, they should behave exactly the same way.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:39 MET