This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[v3] istream/ostream inlines tweaks


Hi,

noticed while working on the last bits of libstdc++/28277. Tested x86/x86_64/ia64-linux, committed to mainline.

Paolo.

///////////////////
2006-10-13  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/istream.tcc (operator>>(__istream_type&
	(*)(__istream_type&)), operator>>(__ios_type& (*)(__ios_type&)),
	operator>>(ios_base& (*)(ios_base&))): Move...
	* include/std/std_istream.h: ... here.
	(operator>>(basic_istream<char,>&, unsigned char&),
	operator>>(basic_istream<char,>&, signed char&),
	operator>>(basic_istream<char,>&, unsigned char*),
	operator>>(basic_istream<char,>&, signed char*)): Mark inline.
	* include/bits/ostream.tcc (operator<<(__ostream_type&
	(*)(__ostream_type&)), operator<<(__ios_type& (*)(__ios_type&)),
	operator<<(ios_base& (*)(ios_base&))): Move...
	* include/std/std_ostream.h: ... here.
	(operator<<(basic_ostream<>&, _CharT),
	operator<<(basic_ostream<>&, char),
	operator<<(basic_ostream<char,>&, char),
	operator<<(basic_ostream<char,>&, signed char),
	operator<<(basic_ostream<char,>&, unsigned char),
	operator<<(basic_ostream<>&, const _CharT*),
	operator<<(basic_ostream<char,>&, const char*),
	operator<<(basic_ostream<char,>&, const signed char*),
	operator<<(basic_ostream<char,>&, const unsigned char*),
	endl(basic_ostream<>&), ends(basic_ostream<>&),
	flush(basic_ostream<>&)): Mark inline.
Index: include/bits/istream.tcc
===================================================================
--- include/bits/istream.tcc	(revision 117688)
+++ include/bits/istream.tcc	(working copy)
@@ -86,30 +86,6 @@
     }
 
   template<typename _CharT, typename _Traits>
-    basic_istream<_CharT, _Traits>&
-    basic_istream<_CharT, _Traits>::
-    operator>>(__istream_type& (*__pf)(__istream_type&))
-    { return __pf(*this); }
-
-  template<typename _CharT, typename _Traits>
-    basic_istream<_CharT, _Traits>&
-    basic_istream<_CharT, _Traits>::
-    operator>>(__ios_type& (*__pf)(__ios_type&))
-    {
-      __pf(*this);
-      return *this;
-    }
-
-  template<typename _CharT, typename _Traits>
-    basic_istream<_CharT, _Traits>&
-    basic_istream<_CharT, _Traits>::
-    operator>>(ios_base& (*__pf)(ios_base&))
-    {
-      __pf(*this);
-      return *this;
-    }
-
-  template<typename _CharT, typename _Traits>
     template<typename _ValueT>
       basic_istream<_CharT, _Traits>&
       basic_istream<_CharT, _Traits>::
Index: include/bits/ostream.tcc
===================================================================
--- include/bits/ostream.tcc	(revision 117693)
+++ include/bits/ostream.tcc	(working copy)
@@ -62,41 +62,6 @@
     }
 
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
-    basic_ostream<_CharT, _Traits>::
-    operator<<(__ostream_type& (*__pf)(__ostream_type&))
-    {
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // DR 60. What is a formatted input function?
-      // The inserters for manipulators are *not* formatted output functions.
-      return __pf(*this);
-    }
-
-  template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
-    basic_ostream<_CharT, _Traits>::
-    operator<<(__ios_type& (*__pf)(__ios_type&))
-    {
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // DR 60. What is a formatted input function?
-      // The inserters for manipulators are *not* formatted output functions.
-      __pf(*this);
-      return *this;
-    }
-
-  template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
-    basic_ostream<_CharT, _Traits>::
-    operator<<(ios_base& (*__pf)(ios_base&))
-    {
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // DR 60. What is a formatted input function?
-      // The inserters for manipulators are *not* formatted output functions.
-      __pf(*this);
-      return *this;
-    }
-
-  template<typename _CharT, typename _Traits>
     template<typename _ValueT>
       basic_ostream<_CharT, _Traits>&
       basic_ostream<_CharT, _Traits>::
Index: include/std/std_istream.h
===================================================================
--- include/std/std_istream.h	(revision 117688)
+++ include/std/std_istream.h	(working copy)
@@ -127,14 +127,23 @@
        *  functions in constructs like "std::cin >> std::ws".  For more
        *  information, see the iomanip header.
       */
-      inline __istream_type&
-      operator>>(__istream_type& (*__pf)(__istream_type&));
+      __istream_type&
+      operator>>(__istream_type& (*__pf)(__istream_type&))
+      { return __pf(*this); }
 
-      inline __istream_type&
-      operator>>(__ios_type& (*__pf)(__ios_type&));
+      __istream_type&
+      operator>>(__ios_type& (*__pf)(__ios_type&))
+      { 
+	__pf(*this);
+	return *this;
+      }
 
-      inline __istream_type&
-      operator>>(ios_base& (*__pf)(ios_base&));
+      __istream_type&
+      operator>>(ios_base& (*__pf)(ios_base&))
+      {
+	__pf(*this);
+	return *this;
+      }
       //@}
       
       // [27.6.1.2.2] arithmetic extractors
@@ -247,7 +256,7 @@
        *  @return  The number of characters extracted by the previous
        *           unformatted input function dispatched for this stream.
       */
-      inline streamsize 
+      streamsize 
       gcount() const 
       { return _M_gcount; }
       
@@ -331,7 +340,7 @@
        *
        *  Returns @c get(s,n,widen('\n')).
       */
-      inline __istream_type& 
+      __istream_type& 
       get(char_type* __s, streamsize __n)
       { return this->get(__s, __n, this->widen('\n')); }
 
@@ -364,7 +373,7 @@
        *
        *  Returns @c get(sb,widen('\n')).
       */
-      inline __istream_type&
+      __istream_type&
       get(__streambuf_type& __sb)
       { return this->get(__sb, this->widen('\n')); }
 
@@ -404,7 +413,7 @@
        *
        *  Returns @c getline(s,n,widen('\n')).
       */
-      inline __istream_type& 
+      __istream_type& 
       getline(char_type* __s, streamsize __n)
       { return this->getline(__s, __n, this->widen('\n')); }
 
@@ -675,7 +684,8 @@
        *  For ease of use, sentries may be converted to booleans.  The
        *  return value is that of the sentry state (true == okay).
       */
-      operator bool() const { return _M_ok; }
+      operator bool() const
+      { return _M_ok; }
 
     private:
       bool _M_ok;
@@ -699,12 +709,12 @@
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
 
   template<class _Traits>
-    basic_istream<char, _Traits>&
+    inline basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     { return (__in >> reinterpret_cast<char&>(__c)); }
 
   template<class _Traits>
-    basic_istream<char, _Traits>&
+    inline basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     { return (__in >> reinterpret_cast<char&>(__c)); }
   //@}
@@ -745,12 +755,12 @@
     operator>>(basic_istream<char>& __in, char* __s);
 
   template<class _Traits>
-    basic_istream<char, _Traits>&
+    inline basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
     { return (__in >> reinterpret_cast<char*>(__s)); }
 
   template<class _Traits>
-    basic_istream<char, _Traits>&
+    inline basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
     { return (__in >> reinterpret_cast<char*>(__s)); }
   //@}
Index: include/std/std_ostream.h
===================================================================
--- include/std/std_ostream.h	(revision 117693)
+++ include/std/std_ostream.h	(working copy)
@@ -131,14 +131,34 @@
        *  functions in constructs like "std::cout << std::endl".  For more
        *  information, see the iomanip header.
       */
-      inline __ostream_type&
-      operator<<(__ostream_type& (*__pf)(__ostream_type&));
-      
-      inline __ostream_type&
-      operator<<(__ios_type& (*__pf)(__ios_type&));
-      
-      inline __ostream_type&
-      operator<<(ios_base& (*__pf) (ios_base&));
+      __ostream_type&
+      operator<<(__ostream_type& (*__pf)(__ostream_type&))
+      {
+	// _GLIBCXX_RESOLVE_LIB_DEFECTS
+	// DR 60. What is a formatted input function?
+	// The inserters for manipulators are *not* formatted output functions.
+	return __pf(*this);
+      }
+
+      __ostream_type&
+      operator<<(__ios_type& (*__pf)(__ios_type&))
+      {
+	// _GLIBCXX_RESOLVE_LIB_DEFECTS
+	// DR 60. What is a formatted input function?
+	// The inserters for manipulators are *not* formatted output functions.
+	__pf(*this);
+	return *this;
+      }
+
+      __ostream_type&
+      operator<<(ios_base& (*__pf) (ios_base&))
+      {
+	// _GLIBCXX_RESOLVE_LIB_DEFECTS
+	// DR 60. What is a formatted input function?
+	// The inserters for manipulators are *not* formatted output functions.
+	__pf(*this);
+	return *this;
+      }
       //@}
 
       // [27.6.2.5.2] arithmetic inserters
@@ -405,7 +425,7 @@
     {
       // Data Members:
       bool 				_M_ok;
-      basic_ostream<_CharT,_Traits>& 	_M_os;
+      basic_ostream<_CharT, _Traits>& 	_M_os;
       
     public:
       /**
@@ -420,7 +440,7 @@
        *  true ("okay").
       */
       explicit
-      sentry(basic_ostream<_CharT,_Traits>& __os);
+      sentry(basic_ostream<_CharT, _Traits>& __os);
 
       /**
        *  @brief  Possibly flushes the stream.
@@ -469,29 +489,29 @@
    *  @c char, the character is widened before insertion.
   */
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
+    inline basic_ostream<_CharT, _Traits>&
     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
     { return __out._M_insert(&__c, 1); }
 
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
+    inline basic_ostream<_CharT, _Traits>&
     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
     { return (__out << __out.widen(__c)); }
 
   // Specialization
   template <class _Traits> 
-    basic_ostream<char, _Traits>&
+    inline basic_ostream<char, _Traits>&
     operator<<(basic_ostream<char, _Traits>& __out, char __c)
     { return __out._M_insert(&__c, 1); }
 
   // Signed and unsigned
   template<class _Traits>
-    basic_ostream<char, _Traits>&
+    inline basic_ostream<char, _Traits>&
     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
     { return (__out << static_cast<char>(__c)); }
   
   template<class _Traits>
-    basic_ostream<char, _Traits>&
+    inline basic_ostream<char, _Traits>&
     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
     { return (__out << static_cast<char>(__c)); }
   //@}
@@ -511,7 +531,7 @@
    *  determined by [22.2.2.2.2]).  @c out.width(0) is then called.
   */
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>&
+    inline basic_ostream<_CharT, _Traits>&
     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
     {
       if (!__s)
@@ -527,7 +547,7 @@
 
   // Partial specializationss
   template<class _Traits>
-    basic_ostream<char, _Traits>&
+    inline basic_ostream<char, _Traits>&
     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
     {
       if (!__s)
@@ -539,12 +559,12 @@
 
   // Signed and unsigned
   template<class _Traits>
-    basic_ostream<char, _Traits>&
+    inline basic_ostream<char, _Traits>&
     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
     { return (__out << reinterpret_cast<const char*>(__s)); }
 
   template<class _Traits>
-    basic_ostream<char, _Traits> &
+    inline basic_ostream<char, _Traits> &
     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
     { return (__out << reinterpret_cast<const char*>(__s)); }
   //@}
@@ -559,7 +579,7 @@
    *  on this subject.
   */
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>& 
+    inline basic_ostream<_CharT, _Traits>& 
     endl(basic_ostream<_CharT, _Traits>& __os)
     { return flush(__os.put(__os.widen('\n'))); }
 
@@ -570,7 +590,7 @@
    *  this correctly writes the ASCII @c NUL character string terminator.
   */
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>& 
+    inline basic_ostream<_CharT, _Traits>& 
     ends(basic_ostream<_CharT, _Traits>& __os)
     { return __os.put(_CharT()); }
   
@@ -580,7 +600,7 @@
    *  This manipulator simply calls the stream's @c flush() member function.
   */
   template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>& 
+    inline basic_ostream<_CharT, _Traits>& 
     flush(basic_ostream<_CharT, _Traits>& __os)
     { return __os.flush(); }
 

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