libstdc++
ostream
Go to the documentation of this file.
00001 // Output streams -*- C++ -*-
00002 
00003 // Copyright (C) 1997-2019 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file include/ostream
00026  *  This is a Standard C++ Library header.
00027  */
00028 
00029 //
00030 // ISO C++ 14882: 27.6.2  Output streams
00031 //
00032 
00033 #ifndef _GLIBCXX_OSTREAM
00034 #define _GLIBCXX_OSTREAM 1
00035 
00036 #pragma GCC system_header
00037 
00038 #include <ios>
00039 #include <bits/ostream_insert.h>
00040 
00041 namespace std _GLIBCXX_VISIBILITY(default)
00042 {
00043 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00044 
00045   /**
00046    *  @brief  Template class basic_ostream.
00047    *  @ingroup io
00048    *
00049    *  @tparam _CharT  Type of character stream.
00050    *  @tparam _Traits  Traits for character type, defaults to
00051    *                   char_traits<_CharT>.
00052    *
00053    *  This is the base class for all output streams.  It provides text
00054    *  formatting of all builtin types, and communicates with any class
00055    *  derived from basic_streambuf to do the actual output.
00056   */
00057   template<typename _CharT, typename _Traits>
00058     class basic_ostream : virtual public basic_ios<_CharT, _Traits>
00059     {
00060     public:
00061       // Types (inherited from basic_ios):
00062       typedef _CharT                                    char_type;
00063       typedef typename _Traits::int_type                int_type;
00064       typedef typename _Traits::pos_type                pos_type;
00065       typedef typename _Traits::off_type                off_type;
00066       typedef _Traits                                   traits_type;
00067 
00068       // Non-standard Types:
00069       typedef basic_streambuf<_CharT, _Traits>          __streambuf_type;
00070       typedef basic_ios<_CharT, _Traits>                __ios_type;
00071       typedef basic_ostream<_CharT, _Traits>            __ostream_type;
00072       typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
00073                                                         __num_put_type;
00074       typedef ctype<_CharT>                             __ctype_type;
00075 
00076       /**
00077        *  @brief  Base constructor.
00078        *
00079        *  This ctor is almost never called by the user directly, rather from
00080        *  derived classes' initialization lists, which pass a pointer to
00081        *  their own stream buffer.
00082       */
00083       explicit
00084       basic_ostream(__streambuf_type* __sb)
00085       { this->init(__sb); }
00086 
00087       /**
00088        *  @brief  Base destructor.
00089        *
00090        *  This does very little apart from providing a virtual base dtor.
00091       */
00092       virtual
00093       ~basic_ostream() { }
00094 
00095       /// Safe prefix/suffix operations.
00096       class sentry;
00097       friend class sentry;
00098 
00099       //@{
00100       /**
00101        *  @brief  Interface for manipulators.
00102        *
00103        *  Manipulators such as @c std::endl and @c std::hex use these
00104        *  functions in constructs like "std::cout << std::endl".  For more
00105        *  information, see the iomanip header.
00106       */
00107       __ostream_type&
00108       operator<<(__ostream_type& (*__pf)(__ostream_type&))
00109       {
00110         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00111         // DR 60. What is a formatted input function?
00112         // The inserters for manipulators are *not* formatted output functions.
00113         return __pf(*this);
00114       }
00115 
00116       __ostream_type&
00117       operator<<(__ios_type& (*__pf)(__ios_type&))
00118       {
00119         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00120         // DR 60. What is a formatted input function?
00121         // The inserters for manipulators are *not* formatted output functions.
00122         __pf(*this);
00123         return *this;
00124       }
00125 
00126       __ostream_type&
00127       operator<<(ios_base& (*__pf) (ios_base&))
00128       {
00129         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00130         // DR 60. What is a formatted input function?
00131         // The inserters for manipulators are *not* formatted output functions.
00132         __pf(*this);
00133         return *this;
00134       }
00135       //@}
00136 
00137       //@{
00138       /**
00139        *  @name Inserters
00140        *
00141        *  All the @c operator<< functions (aka <em>formatted output
00142        *  functions</em>) have some common behavior.  Each starts by
00143        *  constructing a temporary object of type std::basic_ostream::sentry.
00144        *  This can have several effects, concluding with the setting of a
00145        *  status flag; see the sentry documentation for more.
00146        *
00147        *  If the sentry status is good, the function tries to generate
00148        *  whatever data is appropriate for the type of the argument.
00149        *
00150        *  If an exception is thrown during insertion, ios_base::badbit
00151        *  will be turned on in the stream's error state without causing an
00152        *  ios_base::failure to be thrown.  The original exception will then
00153        *  be rethrown.
00154       */
00155 
00156       //@{
00157       /**
00158        *  @brief Integer arithmetic inserters
00159        *  @param  __n A variable of builtin integral type.
00160        *  @return  @c *this if successful
00161        *
00162        *  These functions use the stream's current locale (specifically, the
00163        *  @c num_get facet) to perform numeric formatting.
00164       */
00165       __ostream_type&
00166       operator<<(long __n)
00167       { return _M_insert(__n); }
00168 
00169       __ostream_type&
00170       operator<<(unsigned long __n)
00171       { return _M_insert(__n); }
00172 
00173       __ostream_type&
00174       operator<<(bool __n)
00175       { return _M_insert(__n); }
00176 
00177       __ostream_type&
00178       operator<<(short __n);
00179 
00180       __ostream_type&
00181       operator<<(unsigned short __n)
00182       {
00183         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00184         // 117. basic_ostream uses nonexistent num_put member functions.
00185         return _M_insert(static_cast<unsigned long>(__n));
00186       }
00187 
00188       __ostream_type&
00189       operator<<(int __n);
00190 
00191       __ostream_type&
00192       operator<<(unsigned int __n)
00193       {
00194         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00195         // 117. basic_ostream uses nonexistent num_put member functions.
00196         return _M_insert(static_cast<unsigned long>(__n));
00197       }
00198 
00199 #ifdef _GLIBCXX_USE_LONG_LONG
00200       __ostream_type&
00201       operator<<(long long __n)
00202       { return _M_insert(__n); }
00203 
00204       __ostream_type&
00205       operator<<(unsigned long long __n)
00206       { return _M_insert(__n); }
00207 #endif
00208       //@}
00209 
00210       //@{
00211       /**
00212        *  @brief  Floating point arithmetic inserters
00213        *  @param  __f A variable of builtin floating point type.
00214        *  @return  @c *this if successful
00215        *
00216        *  These functions use the stream's current locale (specifically, the
00217        *  @c num_get facet) to perform numeric formatting.
00218       */
00219       __ostream_type&
00220       operator<<(double __f)
00221       { return _M_insert(__f); }
00222 
00223       __ostream_type&
00224       operator<<(float __f)
00225       {
00226         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00227         // 117. basic_ostream uses nonexistent num_put member functions.
00228         return _M_insert(static_cast<double>(__f));
00229       }
00230 
00231       __ostream_type&
00232       operator<<(long double __f)
00233       { return _M_insert(__f); }
00234       //@}
00235 
00236       /**
00237        *  @brief  Pointer arithmetic inserters
00238        *  @param  __p A variable of pointer type.
00239        *  @return  @c *this if successful
00240        *
00241        *  These functions use the stream's current locale (specifically, the
00242        *  @c num_get facet) to perform numeric formatting.
00243       */
00244       __ostream_type&
00245       operator<<(const void* __p)
00246       { return _M_insert(__p); }
00247 
00248 #if __cplusplus >= 201703L
00249       __ostream_type&
00250       operator<<(nullptr_t)
00251       { return *this << "nullptr"; }
00252 #endif
00253 
00254       /**
00255        *  @brief  Extracting from another streambuf.
00256        *  @param  __sb  A pointer to a streambuf
00257        *
00258        *  This function behaves like one of the basic arithmetic extractors,
00259        *  in that it also constructs a sentry object and has the same error
00260        *  handling behavior.
00261        *
00262        *  If @p __sb is NULL, the stream will set failbit in its error state.
00263        *
00264        *  Characters are extracted from @p __sb and inserted into @c *this
00265        *  until one of the following occurs:
00266        *
00267        *  - the input stream reaches end-of-file,
00268        *  - insertion into the output sequence fails (in this case, the
00269        *    character that would have been inserted is not extracted), or
00270        *  - an exception occurs while getting a character from @p __sb, which
00271        *    sets failbit in the error state
00272        *
00273        *  If the function inserts no characters, failbit is set.
00274       */
00275       __ostream_type&
00276       operator<<(__streambuf_type* __sb);
00277       //@}
00278 
00279       //@{
00280       /**
00281        *  @name Unformatted Output Functions
00282        *
00283        *  All the unformatted output functions have some common behavior.
00284        *  Each starts by constructing a temporary object of type
00285        *  std::basic_ostream::sentry.  This has several effects, concluding
00286        *  with the setting of a status flag; see the sentry documentation
00287        *  for more.
00288        *
00289        *  If the sentry status is good, the function tries to generate
00290        *  whatever data is appropriate for the type of the argument.
00291        *
00292        *  If an exception is thrown during insertion, ios_base::badbit
00293        *  will be turned on in the stream's error state.  If badbit is on in
00294        *  the stream's exceptions mask, the exception will be rethrown
00295        *  without completing its actions.
00296       */
00297 
00298       /**
00299        *  @brief  Simple insertion.
00300        *  @param  __c  The character to insert.
00301        *  @return  *this
00302        *
00303        *  Tries to insert @p __c.
00304        *
00305        *  @note  This function is not overloaded on signed char and
00306        *         unsigned char.
00307       */
00308       __ostream_type&
00309       put(char_type __c);
00310 
00311       /**
00312        *  @brief  Core write functionality, without sentry.
00313        *  @param  __s  The array to insert.
00314        *  @param  __n  Maximum number of characters to insert.
00315       */
00316       void
00317       _M_write(const char_type* __s, streamsize __n)
00318       {
00319         const streamsize __put = this->rdbuf()->sputn(__s, __n);
00320         if (__put != __n)
00321           this->setstate(ios_base::badbit);
00322       }
00323 
00324       /**
00325        *  @brief  Character string insertion.
00326        *  @param  __s  The array to insert.
00327        *  @param  __n  Maximum number of characters to insert.
00328        *  @return  *this
00329        *
00330        *  Characters are copied from @p __s and inserted into the stream until
00331        *  one of the following happens:
00332        *
00333        *  - @p __n characters are inserted
00334        *  - inserting into the output sequence fails (in this case, badbit
00335        *    will be set in the stream's error state)
00336        *
00337        *  @note  This function is not overloaded on signed char and
00338        *         unsigned char.
00339       */
00340       __ostream_type&
00341       write(const char_type* __s, streamsize __n);
00342       //@}
00343 
00344       /**
00345        *  @brief  Synchronizing the stream buffer.
00346        *  @return  *this
00347        *
00348        *  If @c rdbuf() is a null pointer, changes nothing.
00349        *
00350        *  Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
00351        *  sets badbit.
00352       */
00353       __ostream_type&
00354       flush();
00355 
00356       /**
00357        *  @brief  Getting the current write position.
00358        *  @return  A file position object.
00359        *
00360        *  If @c fail() is not false, returns @c pos_type(-1) to indicate
00361        *  failure.  Otherwise returns @c rdbuf()->pubseekoff(0,cur,out).
00362       */
00363       pos_type
00364       tellp();
00365 
00366       /**
00367        *  @brief  Changing the current write position.
00368        *  @param  __pos  A file position object.
00369        *  @return  *this
00370        *
00371        *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos).  If
00372        *  that function fails, sets failbit.
00373       */
00374       __ostream_type&
00375       seekp(pos_type);
00376 
00377       /**
00378        *  @brief  Changing the current write position.
00379        *  @param  __off  A file offset object.
00380        *  @param  __dir  The direction in which to seek.
00381        *  @return  *this
00382        *
00383        *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
00384        *  If that function fails, sets failbit.
00385       */
00386        __ostream_type&
00387       seekp(off_type, ios_base::seekdir);
00388 
00389     protected:
00390       basic_ostream()
00391       { this->init(0); }
00392 
00393 #if __cplusplus >= 201103L
00394       // Non-standard constructor that does not call init()
00395       basic_ostream(basic_iostream<_CharT, _Traits>&) { }
00396 
00397       basic_ostream(const basic_ostream&) = delete;
00398 
00399       basic_ostream(basic_ostream&& __rhs)
00400       : __ios_type()
00401       { __ios_type::move(__rhs); }
00402 
00403       // 27.7.3.3 Assign/swap
00404 
00405       basic_ostream& operator=(const basic_ostream&) = delete;
00406 
00407       basic_ostream&
00408       operator=(basic_ostream&& __rhs)
00409       {
00410         swap(__rhs);
00411         return *this;
00412       }
00413 
00414       void
00415       swap(basic_ostream& __rhs)
00416       { __ios_type::swap(__rhs); }
00417 #endif
00418 
00419       template<typename _ValueT>
00420         __ostream_type&
00421         _M_insert(_ValueT __v);
00422     };
00423 
00424   /**
00425    *  @brief  Performs setup work for output streams.
00426    *
00427    *  Objects of this class are created before all of the standard
00428    *  inserters are run.  It is responsible for <em>exception-safe prefix and
00429    *  suffix operations</em>.
00430   */
00431   template <typename _CharT, typename _Traits>
00432     class basic_ostream<_CharT, _Traits>::sentry
00433     {
00434       // Data Members.
00435       bool                              _M_ok;
00436       basic_ostream<_CharT, _Traits>&   _M_os;
00437 
00438     public:
00439       /**
00440        *  @brief  The constructor performs preparatory work.
00441        *  @param  __os  The output stream to guard.
00442        *
00443        *  If the stream state is good (@a __os.good() is true), then if the
00444        *  stream is tied to another output stream, @c is.tie()->flush()
00445        *  is called to synchronize the output sequences.
00446        *
00447        *  If the stream state is still good, then the sentry state becomes
00448        *  true (@a okay).
00449       */
00450       explicit
00451       sentry(basic_ostream<_CharT, _Traits>& __os);
00452 
00453 #pragma GCC diagnostic push
00454 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
00455       /**
00456        *  @brief  Possibly flushes the stream.
00457        *
00458        *  If @c ios_base::unitbuf is set in @c os.flags(), and
00459        *  @c std::uncaught_exception() is true, the sentry destructor calls
00460        *  @c flush() on the output stream.
00461       */
00462       ~sentry()
00463       {
00464         // XXX MT
00465         if (bool(_M_os.flags() & ios_base::unitbuf) && !uncaught_exception())
00466           {
00467             // Can't call flush directly or else will get into recursive lock.
00468             if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
00469               _M_os.setstate(ios_base::badbit);
00470           }
00471       }
00472 #pragma GCC diagnostic pop
00473 
00474       /**
00475        *  @brief  Quick status checking.
00476        *  @return  The sentry state.
00477        *
00478        *  For ease of use, sentries may be converted to booleans.  The
00479        *  return value is that of the sentry state (true == okay).
00480       */
00481 #if __cplusplus >= 201103L
00482       explicit
00483 #endif
00484       operator bool() const
00485       { return _M_ok; }
00486     };
00487 
00488   //@{
00489   /**
00490    *  @brief  Character inserters
00491    *  @param  __out  An output stream.
00492    *  @param  __c  A character.
00493    *  @return  out
00494    *
00495    *  Behaves like one of the formatted arithmetic inserters described in
00496    *  std::basic_ostream.  After constructing a sentry object with good
00497    *  status, this function inserts a single character and any required
00498    *  padding (as determined by [22.2.2.2.2]).  @c __out.width(0) is then
00499    *  called.
00500    *
00501    *  If @p __c is of type @c char and the character type of the stream is not
00502    *  @c char, the character is widened before insertion.
00503   */
00504   template<typename _CharT, typename _Traits>
00505     inline basic_ostream<_CharT, _Traits>&
00506     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
00507     { return __ostream_insert(__out, &__c, 1); }
00508 
00509   template<typename _CharT, typename _Traits>
00510     inline basic_ostream<_CharT, _Traits>&
00511     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
00512     { return (__out << __out.widen(__c)); }
00513 
00514   // Specialization
00515   template <class _Traits>
00516     inline basic_ostream<char, _Traits>&
00517     operator<<(basic_ostream<char, _Traits>& __out, char __c)
00518     { return __ostream_insert(__out, &__c, 1); }
00519 
00520   // Signed and unsigned
00521   template<class _Traits>
00522     inline basic_ostream<char, _Traits>&
00523     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
00524     { return (__out << static_cast<char>(__c)); }
00525 
00526   template<class _Traits>
00527     inline basic_ostream<char, _Traits>&
00528     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
00529     { return (__out << static_cast<char>(__c)); }
00530   //@}
00531 
00532   //@{
00533   /**
00534    *  @brief  String inserters
00535    *  @param  __out  An output stream.
00536    *  @param  __s  A character string.
00537    *  @return  out
00538    *  @pre  @p __s must be a non-NULL pointer
00539    *
00540    *  Behaves like one of the formatted arithmetic inserters described in
00541    *  std::basic_ostream.  After constructing a sentry object with good
00542    *  status, this function inserts @c traits::length(__s) characters starting
00543    *  at @p __s, widened if necessary, followed by any required padding (as
00544    *  determined by [22.2.2.2.2]).  @c __out.width(0) is then called.
00545   */
00546   template<typename _CharT, typename _Traits>
00547     inline basic_ostream<_CharT, _Traits>&
00548     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
00549     {
00550       if (!__s)
00551         __out.setstate(ios_base::badbit);
00552       else
00553         __ostream_insert(__out, __s,
00554                          static_cast<streamsize>(_Traits::length(__s)));
00555       return __out;
00556     }
00557 
00558   template<typename _CharT, typename _Traits>
00559     basic_ostream<_CharT, _Traits> &
00560     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
00561 
00562   // Partial specializations
00563   template<class _Traits>
00564     inline basic_ostream<char, _Traits>&
00565     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
00566     {
00567       if (!__s)
00568         __out.setstate(ios_base::badbit);
00569       else
00570         __ostream_insert(__out, __s,
00571                          static_cast<streamsize>(_Traits::length(__s)));
00572       return __out;
00573     }
00574 
00575   // Signed and unsigned
00576   template<class _Traits>
00577     inline basic_ostream<char, _Traits>&
00578     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
00579     { return (__out << reinterpret_cast<const char*>(__s)); }
00580 
00581   template<class _Traits>
00582     inline basic_ostream<char, _Traits> &
00583     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
00584     { return (__out << reinterpret_cast<const char*>(__s)); }
00585   //@}
00586 
00587   // Standard basic_ostream manipulators
00588 
00589   /**
00590    *  @brief  Write a newline and flush the stream.
00591    *
00592    *  This manipulator is often mistakenly used when a simple newline is
00593    *  desired, leading to poor buffering performance.  See
00594    *  https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering
00595    *  for more on this subject.
00596   */
00597   template<typename _CharT, typename _Traits>
00598     inline basic_ostream<_CharT, _Traits>&
00599     endl(basic_ostream<_CharT, _Traits>& __os)
00600     { return flush(__os.put(__os.widen('\n'))); }
00601 
00602   /**
00603    *  @brief  Write a null character into the output sequence.
00604    *
00605    *  <em>Null character</em> is @c CharT() by definition.  For CharT
00606    *  of @c char, this correctly writes the ASCII @c NUL character
00607    *  string terminator.
00608   */
00609   template<typename _CharT, typename _Traits>
00610     inline basic_ostream<_CharT, _Traits>&
00611     ends(basic_ostream<_CharT, _Traits>& __os)
00612     { return __os.put(_CharT()); }
00613 
00614   /**
00615    *  @brief  Flushes the output stream.
00616    *
00617    *  This manipulator simply calls the stream's @c flush() member function.
00618   */
00619   template<typename _CharT, typename _Traits>
00620     inline basic_ostream<_CharT, _Traits>&
00621     flush(basic_ostream<_CharT, _Traits>& __os)
00622     { return __os.flush(); }
00623 
00624 #if __cplusplus >= 201103L
00625   template<typename _Ch, typename _Up>
00626     basic_ostream<_Ch, _Up>&
00627     __is_convertible_to_basic_ostream_test(basic_ostream<_Ch, _Up>*);
00628 
00629   template<typename _Tp, typename = void>
00630     struct __is_convertible_to_basic_ostream_impl
00631     {
00632       using __ostream_type = void;
00633     };
00634 
00635   template<typename _Tp>
00636     using __do_is_convertible_to_basic_ostream_impl =
00637     decltype(__is_convertible_to_basic_ostream_test
00638              (declval<typename remove_reference<_Tp>::type*>()));
00639 
00640   template<typename _Tp>
00641     struct __is_convertible_to_basic_ostream_impl
00642     <_Tp,
00643      __void_t<__do_is_convertible_to_basic_ostream_impl<_Tp>>>
00644     {
00645       using __ostream_type =
00646         __do_is_convertible_to_basic_ostream_impl<_Tp>;
00647     };
00648 
00649   template<typename _Tp>
00650     struct __is_convertible_to_basic_ostream
00651     : __is_convertible_to_basic_ostream_impl<_Tp>
00652     {
00653     public:
00654       using type = __not_<is_void<
00655         typename __is_convertible_to_basic_ostream_impl<_Tp>::__ostream_type>>;
00656       constexpr static bool value = type::value;
00657     };
00658 
00659   template<typename _Ostream, typename _Tp, typename = void>
00660     struct __is_insertable : false_type {};
00661 
00662   template<typename _Ostream, typename _Tp>
00663     struct __is_insertable<_Ostream, _Tp,
00664                            __void_t<decltype(declval<_Ostream&>()
00665                                              << declval<const _Tp&>())>>
00666                                     : true_type {};
00667 
00668   template<typename _Ostream>
00669     using __rvalue_ostream_type =
00670       typename __is_convertible_to_basic_ostream<
00671         _Ostream>::__ostream_type;
00672 
00673   /**
00674    *  @brief  Generic inserter for rvalue stream
00675    *  @param  __os  An input stream.
00676    *  @param  __x  A reference to the object being inserted.
00677    *  @return  os
00678    *
00679    *  This is just a forwarding function to allow insertion to
00680    *  rvalue streams since they won't bind to the inserter functions
00681    *  that take an lvalue reference.
00682   */
00683   template<typename _Ostream, typename _Tp>
00684     inline
00685     typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,
00686                               __is_convertible_to_basic_ostream<_Ostream>,
00687                               __is_insertable<
00688                                 __rvalue_ostream_type<_Ostream>,
00689                                 const _Tp&>>::value,
00690                        __rvalue_ostream_type<_Ostream>>::type
00691     operator<<(_Ostream&& __os, const _Tp& __x)
00692     {
00693       __rvalue_ostream_type<_Ostream> __ret_os = __os;
00694       __ret_os << __x;
00695       return __ret_os;
00696     }
00697 #endif // C++11
00698 
00699 _GLIBCXX_END_NAMESPACE_VERSION
00700 } // namespace std
00701 
00702 #include <bits/ostream.tcc>
00703 
00704 #endif  /* _GLIBCXX_OSTREAM */