// Output streams -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007
+// 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
+// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
/** @file ostream
* This is a Standard C++ Library header.
#include <ios>
#include <bits/ostream_insert.h>
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-# include <system_error>
-#endif
-
_GLIBCXX_BEGIN_NAMESPACE(std)
// [27.6.2.1] Template class basic_ostream
/**
* @brief Controlling output.
+ * @ingroup io
*
* This is the base class for all output streams. It provides text
* formatting of all builtin types, and communicates with any class
/**
* @brief Interface for manipulators.
*
- * Manuipulators such as @c std::endl and @c std::hex use these
+ * Manipulators such as @c std::endl and @c std::hex use these
* functions in constructs like "std::cout << std::endl". For more
* information, see the iomanip header.
*/
seekp(off_type, ios_base::seekdir);
protected:
- explicit
- basic_ostream() { }
+ basic_ostream()
+ { this->init(0); }
template<typename _ValueT>
__ostream_type&
*
* Objects of this class are created before all of the standard
* inserters are run. It is responsible for "exception-safe prefix and
- * suffix operations." Additional actions may be added by the
- * implementation, and we list them in
- * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
- * under [27.6] notes.
+ * suffix operations."
*/
template <typename _CharT, typename _Traits>
class basic_ostream<_CharT, _Traits>::sentry
{
- // Data Members:
+ // Data Members.
bool _M_ok;
basic_ostream<_CharT, _Traits>& _M_os;
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+#endif
operator bool() const
{ return _M_ok; }
};
basic_ostream<_CharT, _Traits> &
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
- // Partial specializationss
+ // Partial specializations
template<class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
{ return (__out << reinterpret_cast<const char*>(__s)); }
//@}
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __out, const error_code& __e)
- { return (__out << __e.category().name().c_str() << ':' << __e.value()); }
-#endif
-
// [27.6.2.7] standard basic_ostream manipulators
/**
* @brief Write a newline and flush the stream.
*
* This manipulator is often mistakenly used when a simple newline is
* desired, leading to poor buffering performance. See
- * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more
- * on this subject.
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
+ * for more on this subject.
*/
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
flush(basic_ostream<_CharT, _Traits>& __os)
{ return __os.flush(); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // [27.7.2.9] Rvalue stream insertion
+ /**
+ * @brief Generic inserter for rvalue stream
+ * @param os An input stream.
+ * @param x A reference to the object being inserted.
+ * @return os
+ *
+ * This is just a forwarding function to allow insertion to
+ * rvalue streams since they won't bind to the inserter functions
+ * that take an lvalue reference.
+ */
+ template<typename _CharT, typename _Traits, typename _Tp>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
+ { return (__os << __x); }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE