[Patch] Fix libstdc++/9561

Benjamin Kosnik bkoz@redhat.com
Fri Mar 7 16:10:00 GMT 2003


>2003-02-24  Jerry Quinn  <jlquinn@us.ibm.com>
>
>        * include/bits/basic_ios.h (_M_setstate): New.
>	* include/bits/ostream.tcc (operator<<): Use it.
>	* include/std/std_ostream.h (operator<<): Make friends.

This patch is the right idea, thanks. However, a couple of things.

1) this needs to be done for istream.tcc as well

2) needs testcases for both istream and ostream bits

3) template friend bits should look (something) like:

Index: include/std/std_ostream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_ostream.h,v
retrieving revision 1.7
diff -c -p -r1.7 std_ostream.h
*** include/std/std_ostream.h	7 Feb 2003 00:26:44 -0000	1.7
--- include/std/std_ostream.h	7 Mar 2003 07:53:07 -0000
*************** namespace std
*** 73,78 ****
--- 73,102 ----
        typedef num_put<_CharT, __ostreambuf_iter>        __numput_type;
        typedef ctype<_CharT>           			__ctype_type;
  
+       template<typename _CharT2, typename _Traits2>
+         friend basic_ostream<_CharT2, _Traits2>&
+         operator<<(basic_ostream<_CharT2, _Traits2>&, _CharT2);
+ 
+ #if 1
+       template<typename _Traits2>
+         friend basic_ostream<char, _Traits2>&
+         operator<<(basic_ostream<char, _Traits2>&, char);
+ #endif
+ 
+       template<typename _CharT2, typename _Traits2>
+         friend basic_ostream<_CharT2, _Traits2>&
+         operator<<(basic_ostream<_CharT2, _Traits2>&, const _CharT2*);
+ 
+ #if 1
+       template<typename _Traits2>
+         friend basic_ostream<char, _Traits2>&
+         operator<<(basic_ostream<char, _Traits2>&, const char*);
+ #endif
+ 
+       template<typename _CharT2, typename _Traits2>
+         friend basic_ostream<_CharT2, _Traits2>&
+         operator<<(basic_ostream<_CharT2, _Traits2>&, const char*);
+ 
        // [27.6.2.2] constructor/destructor
        /**
         *  @brief  Base constructor.

At the moment, the #if/#endif bits are necessary, but I'm not quite sure why.

-benjamin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.20030307-1
Type: application/octet-stream
Size: 12718 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030307/564928ff/attachment.obj>


More information about the Libstdc++ mailing list