197403Sobrien// Output streams -*- C++ -*- 297403Sobrien 3169691Skan// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4169691Skan// 2006, 2007 597403Sobrien// Free Software Foundation, Inc. 697403Sobrien// 797403Sobrien// This file is part of the GNU ISO C++ Library. This library is free 897403Sobrien// software; you can redistribute it and/or modify it under the 997403Sobrien// terms of the GNU General Public License as published by the 1097403Sobrien// Free Software Foundation; either version 2, or (at your option) 1197403Sobrien// any later version. 1297403Sobrien 1397403Sobrien// This library is distributed in the hope that it will be useful, 1497403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of 1597403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1697403Sobrien// GNU General Public License for more details. 1797403Sobrien 1897403Sobrien// You should have received a copy of the GNU General Public License along 1997403Sobrien// with this library; see the file COPYING. If not, write to the Free 20169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 2197403Sobrien// USA. 2297403Sobrien 2397403Sobrien// As a special exception, you may use this file as part of a free software 2497403Sobrien// library without restriction. Specifically, if other files instantiate 2597403Sobrien// templates or use macros or inline functions from this file, or you compile 2697403Sobrien// this file and link it with other files to produce an executable, this 2797403Sobrien// file does not by itself cause the resulting executable to be covered by 2897403Sobrien// the GNU General Public License. This exception does not however 2997403Sobrien// invalidate any other reasons why the executable file might be covered by 3097403Sobrien// the GNU General Public License. 3197403Sobrien 32169691Skan/** @file ostream 33169691Skan * This is a Standard C++ Library header. 34169691Skan */ 35169691Skan 3697403Sobrien// 3797403Sobrien// ISO C++ 14882: 27.6.2 Output streams 3897403Sobrien// 3997403Sobrien 40132720Skan#ifndef _GLIBCXX_OSTREAM 41132720Skan#define _GLIBCXX_OSTREAM 1 4297403Sobrien 4397403Sobrien#pragma GCC system_header 4497403Sobrien 4597403Sobrien#include <ios> 46169691Skan#include <bits/ostream_insert.h> 4797403Sobrien 48169691Skan_GLIBCXX_BEGIN_NAMESPACE(std) 49169691Skan 50117397Skan // [27.6.2.1] Template class basic_ostream 51117397Skan /** 52117397Skan * @brief Controlling output. 53117397Skan * 54117397Skan * This is the base class for all output streams. It provides text 55117397Skan * formatting of all builtin types, and communicates with any class 56117397Skan * derived from basic_streambuf to do the actual output. 57117397Skan */ 5897403Sobrien template<typename _CharT, typename _Traits> 5997403Sobrien class basic_ostream : virtual public basic_ios<_CharT, _Traits> 6097403Sobrien { 6197403Sobrien public: 6297403Sobrien // Types (inherited from basic_ios (27.4.4)): 6397403Sobrien typedef _CharT char_type; 6497403Sobrien typedef typename _Traits::int_type int_type; 6597403Sobrien typedef typename _Traits::pos_type pos_type; 6697403Sobrien typedef typename _Traits::off_type off_type; 6797403Sobrien typedef _Traits traits_type; 6897403Sobrien 6997403Sobrien // Non-standard Types: 7097403Sobrien typedef basic_streambuf<_CharT, _Traits> __streambuf_type; 7197403Sobrien typedef basic_ios<_CharT, _Traits> __ios_type; 7297403Sobrien typedef basic_ostream<_CharT, _Traits> __ostream_type; 73132720Skan typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > 74132720Skan __num_put_type; 7597403Sobrien typedef ctype<_CharT> __ctype_type; 7697403Sobrien 77117397Skan // [27.6.2.2] constructor/destructor 78117397Skan /** 79117397Skan * @brief Base constructor. 80117397Skan * 81117397Skan * This ctor is almost never called by the user directly, rather from 82117397Skan * derived classes' initialization lists, which pass a pointer to 83117397Skan * their own stream buffer. 84117397Skan */ 8597403Sobrien explicit 8697403Sobrien basic_ostream(__streambuf_type* __sb) 8797403Sobrien { this->init(__sb); } 8897403Sobrien 89117397Skan /** 90117397Skan * @brief Base destructor. 91117397Skan * 92117397Skan * This does very little apart from providing a virtual base dtor. 93117397Skan */ 9497403Sobrien virtual 9597403Sobrien ~basic_ostream() { } 9697403Sobrien 97117397Skan // [27.6.2.3] prefix/suffix 9897403Sobrien class sentry; 9997403Sobrien friend class sentry; 10097403Sobrien 101117397Skan // [27.6.2.5] formatted output 102117397Skan // [27.6.2.5.3] basic_ostream::operator<< 103117397Skan //@{ 104117397Skan /** 105117397Skan * @brief Interface for manipulators. 106117397Skan * 107117397Skan * Manuipulators such as @c std::endl and @c std::hex use these 108117397Skan * functions in constructs like "std::cout << std::endl". For more 109117397Skan * information, see the iomanip header. 110117397Skan */ 111169691Skan __ostream_type& 112169691Skan operator<<(__ostream_type& (*__pf)(__ostream_type&)) 113169691Skan { 114169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 115169691Skan // DR 60. What is a formatted input function? 116169691Skan // The inserters for manipulators are *not* formatted output functions. 117169691Skan return __pf(*this); 118169691Skan } 119169691Skan 120169691Skan __ostream_type& 121169691Skan operator<<(__ios_type& (*__pf)(__ios_type&)) 122169691Skan { 123169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 124169691Skan // DR 60. What is a formatted input function? 125169691Skan // The inserters for manipulators are *not* formatted output functions. 126169691Skan __pf(*this); 127169691Skan return *this; 128169691Skan } 129169691Skan 130169691Skan __ostream_type& 131169691Skan operator<<(ios_base& (*__pf) (ios_base&)) 132169691Skan { 133169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 134169691Skan // DR 60. What is a formatted input function? 135169691Skan // The inserters for manipulators are *not* formatted output functions. 136169691Skan __pf(*this); 137169691Skan return *this; 138169691Skan } 139117397Skan //@} 14097403Sobrien 141117397Skan // [27.6.2.5.2] arithmetic inserters 142117397Skan /** 143117397Skan * @name Arithmetic Inserters 144117397Skan * 145117397Skan * All the @c operator<< functions (aka <em>formatted output 146117397Skan * functions</em>) have some common behavior. Each starts by 147117397Skan * constructing a temporary object of type std::basic_ostream::sentry. 148117397Skan * This can have several effects, concluding with the setting of a 149117397Skan * status flag; see the sentry documentation for more. 150117397Skan * 151117397Skan * If the sentry status is good, the function tries to generate 152117397Skan * whatever data is appropriate for the type of the argument. 153117397Skan * 154117397Skan * If an exception is thrown during insertion, ios_base::badbit 155117397Skan * will be turned on in the stream's error state without causing an 156117397Skan * ios_base::failure to be thrown. The original exception will then 157117397Skan * be rethrown. 158117397Skan */ 159117397Skan //@{ 160117397Skan /** 161117397Skan * @brief Basic arithmetic inserters 162117397Skan * @param A variable of builtin type. 163117397Skan * @return @c *this if successful 164117397Skan * 165117397Skan * These functions use the stream's current locale (specifically, the 166117397Skan * @c num_get facet) to perform numeric formatting. 167117397Skan */ 16897403Sobrien __ostream_type& 169169691Skan operator<<(long __n) 170169691Skan { return _M_insert(__n); } 17197403Sobrien 17297403Sobrien __ostream_type& 173169691Skan operator<<(unsigned long __n) 174169691Skan { return _M_insert(__n); } 17597403Sobrien 17697403Sobrien __ostream_type& 177169691Skan operator<<(bool __n) 178169691Skan { return _M_insert(__n); } 17997403Sobrien 18097403Sobrien __ostream_type& 181169691Skan operator<<(short __n); 18297403Sobrien 18397403Sobrien __ostream_type& 18497403Sobrien operator<<(unsigned short __n) 185169691Skan { 186169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 187169691Skan // 117. basic_ostream uses nonexistent num_put member functions. 188169691Skan return _M_insert(static_cast<unsigned long>(__n)); 189169691Skan } 19097403Sobrien 19197403Sobrien __ostream_type& 192169691Skan operator<<(int __n); 19397403Sobrien 19497403Sobrien __ostream_type& 19597403Sobrien operator<<(unsigned int __n) 196169691Skan { 197169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 198169691Skan // 117. basic_ostream uses nonexistent num_put member functions. 199169691Skan return _M_insert(static_cast<unsigned long>(__n)); 200169691Skan } 20197403Sobrien 202132720Skan#ifdef _GLIBCXX_USE_LONG_LONG 20397403Sobrien __ostream_type& 204169691Skan operator<<(long long __n) 205169691Skan { return _M_insert(__n); } 20697403Sobrien 20797403Sobrien __ostream_type& 208169691Skan operator<<(unsigned long long __n) 209169691Skan { return _M_insert(__n); } 21097403Sobrien#endif 21197403Sobrien 21297403Sobrien __ostream_type& 213169691Skan operator<<(double __f) 214169691Skan { return _M_insert(__f); } 21597403Sobrien 21697403Sobrien __ostream_type& 21797403Sobrien operator<<(float __f) 218169691Skan { 219169691Skan // _GLIBCXX_RESOLVE_LIB_DEFECTS 220169691Skan // 117. basic_ostream uses nonexistent num_put member functions. 221169691Skan return _M_insert(static_cast<double>(__f)); 222169691Skan } 22397403Sobrien 22497403Sobrien __ostream_type& 225169691Skan operator<<(long double __f) 226169691Skan { return _M_insert(__f); } 22797403Sobrien 22897403Sobrien __ostream_type& 229169691Skan operator<<(const void* __p) 230169691Skan { return _M_insert(__p); } 23197403Sobrien 232117397Skan /** 233117397Skan * @brief Extracting from another streambuf. 234117397Skan * @param sb A pointer to a streambuf 235117397Skan * 236117397Skan * This function behaves like one of the basic arithmetic extractors, 237132720Skan * in that it also constructs a sentry object and has the same error 238117397Skan * handling behavior. 239117397Skan * 240117397Skan * If @a sb is NULL, the stream will set failbit in its error state. 241117397Skan * 242117397Skan * Characters are extracted from @a sb and inserted into @c *this 243117397Skan * until one of the following occurs: 244117397Skan * 245117397Skan * - the input stream reaches end-of-file, 246117397Skan * - insertion into the output sequence fails (in this case, the 247117397Skan * character that would have been inserted is not extracted), or 248117397Skan * - an exception occurs while getting a character from @a sb, which 249117397Skan * sets failbit in the error state 250117397Skan * 251117397Skan * If the function inserts no characters, failbit is set. 252117397Skan */ 25397403Sobrien __ostream_type& 25497403Sobrien operator<<(__streambuf_type* __sb); 255117397Skan //@} 25697403Sobrien 257117397Skan // [27.6.2.6] unformatted output functions 258117397Skan /** 259117397Skan * @name Unformatted Output Functions 260117397Skan * 261117397Skan * All the unformatted output functions have some common behavior. 262117397Skan * Each starts by constructing a temporary object of type 263117397Skan * std::basic_ostream::sentry. This has several effects, concluding 264117397Skan * with the setting of a status flag; see the sentry documentation 265117397Skan * for more. 266117397Skan * 267117397Skan * If the sentry status is good, the function tries to generate 268117397Skan * whatever data is appropriate for the type of the argument. 269117397Skan * 270117397Skan * If an exception is thrown during insertion, ios_base::badbit 271117397Skan * will be turned on in the stream's error state. If badbit is on in 272117397Skan * the stream's exceptions mask, the exception will be rethrown 273117397Skan * without completing its actions. 274117397Skan */ 275117397Skan //@{ 276117397Skan /** 277117397Skan * @brief Simple insertion. 278117397Skan * @param c The character to insert. 279117397Skan * @return *this 280117397Skan * 281117397Skan * Tries to insert @a c. 282117397Skan * 283117397Skan * @note This function is not overloaded on signed char and 284117397Skan * unsigned char. 285117397Skan */ 28697403Sobrien __ostream_type& 28797403Sobrien put(char_type __c); 28897403Sobrien 289132720Skan // Core write functionality, without sentry. 290132720Skan void 291132720Skan _M_write(const char_type* __s, streamsize __n) 292132720Skan { 293169691Skan const streamsize __put = this->rdbuf()->sputn(__s, __n); 294132720Skan if (__put != __n) 295132720Skan this->setstate(ios_base::badbit); 296132720Skan } 297132720Skan 298117397Skan /** 299117397Skan * @brief Character string insertion. 300117397Skan * @param s The array to insert. 301117397Skan * @param n Maximum number of characters to insert. 302117397Skan * @return *this 303117397Skan * 304117397Skan * Characters are copied from @a s and inserted into the stream until 305117397Skan * one of the following happens: 306117397Skan * 307117397Skan * - @a n characters are inserted 308117397Skan * - inserting into the output sequence fails (in this case, badbit 309117397Skan * will be set in the stream's error state) 310117397Skan * 311117397Skan * @note This function is not overloaded on signed char and 312117397Skan * unsigned char. 313117397Skan */ 31497403Sobrien __ostream_type& 31597403Sobrien write(const char_type* __s, streamsize __n); 316117397Skan //@} 31797403Sobrien 318117397Skan /** 319117397Skan * @brief Synchronizing the stream buffer. 320117397Skan * @return *this 321117397Skan * 322117397Skan * If @c rdbuf() is a null pointer, changes nothing. 323117397Skan * 324117397Skan * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, 325117397Skan * sets badbit. 326117397Skan */ 32797403Sobrien __ostream_type& 32897403Sobrien flush(); 32997403Sobrien 330117397Skan // [27.6.2.4] seek members 331117397Skan /** 332117397Skan * @brief Getting the current write position. 333117397Skan * @return A file position object. 334117397Skan * 335117397Skan * If @c fail() is not false, returns @c pos_type(-1) to indicate 336117397Skan * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out). 337117397Skan */ 33897403Sobrien pos_type 33997403Sobrien tellp(); 34097403Sobrien 341117397Skan /** 342117397Skan * @brief Changing the current write position. 343117397Skan * @param pos A file position object. 344117397Skan * @return *this 345117397Skan * 346117397Skan * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If 347117397Skan * that function fails, sets failbit. 348117397Skan */ 34997403Sobrien __ostream_type& 35097403Sobrien seekp(pos_type); 35197403Sobrien 352117397Skan /** 353117397Skan * @brief Changing the current write position. 354117397Skan * @param off A file offset object. 355117397Skan * @param dir The direction in which to seek. 356117397Skan * @return *this 357117397Skan * 358117397Skan * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). 359117397Skan * If that function fails, sets failbit. 360117397Skan */ 361117397Skan __ostream_type& 36297403Sobrien seekp(off_type, ios_base::seekdir); 363132720Skan 364132720Skan protected: 365132720Skan explicit 366132720Skan basic_ostream() { } 367169691Skan 368169691Skan template<typename _ValueT> 369169691Skan __ostream_type& 370169691Skan _M_insert(_ValueT __v); 37197403Sobrien }; 37297403Sobrien 373117397Skan /** 374117397Skan * @brief Performs setup work for output streams. 375117397Skan * 376117397Skan * Objects of this class are created before all of the standard 377117397Skan * inserters are run. It is responsible for "exception-safe prefix and 378117397Skan * suffix operations." Additional actions may be added by the 379117397Skan * implementation, and we list them in 380117397Skan * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5 381117397Skan * under [27.6] notes. 382117397Skan */ 38397403Sobrien template <typename _CharT, typename _Traits> 38497403Sobrien class basic_ostream<_CharT, _Traits>::sentry 38597403Sobrien { 38697403Sobrien // Data Members: 38797403Sobrien bool _M_ok; 388169691Skan basic_ostream<_CharT, _Traits>& _M_os; 38997403Sobrien 39097403Sobrien public: 391117397Skan /** 392117397Skan * @brief The constructor performs preparatory work. 393117397Skan * @param os The output stream to guard. 394117397Skan * 395117397Skan * If the stream state is good (@a os.good() is true), then if the 396117397Skan * stream is tied to another output stream, @c is.tie()->flush() 397117397Skan * is called to synchronize the output sequences. 398117397Skan * 399117397Skan * If the stream state is still good, then the sentry state becomes 400117397Skan * true ("okay"). 401117397Skan */ 40297403Sobrien explicit 403169691Skan sentry(basic_ostream<_CharT, _Traits>& __os); 40497403Sobrien 405117397Skan /** 406117397Skan * @brief Possibly flushes the stream. 407117397Skan * 408117397Skan * If @c ios_base::unitbuf is set in @c os.flags(), and 409117397Skan * @c std::uncaught_exception() is true, the sentry destructor calls 410117397Skan * @c flush() on the output stream. 411117397Skan */ 41297403Sobrien ~sentry() 41397403Sobrien { 41497403Sobrien // XXX MT 41597403Sobrien if (_M_os.flags() & ios_base::unitbuf && !uncaught_exception()) 41697403Sobrien { 41797403Sobrien // Can't call flush directly or else will get into recursive lock. 41897403Sobrien if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1) 41997403Sobrien _M_os.setstate(ios_base::badbit); 42097403Sobrien } 42197403Sobrien } 42297403Sobrien 423117397Skan /** 424117397Skan * @brief Quick status checking. 425117397Skan * @return The sentry state. 426117397Skan * 427117397Skan * For ease of use, sentries may be converted to booleans. The 428117397Skan * return value is that of the sentry state (true == okay). 429117397Skan */ 430132720Skan operator bool() const 43197403Sobrien { return _M_ok; } 43297403Sobrien }; 43397403Sobrien 434117397Skan // [27.6.2.5.4] character insertion templates 435117397Skan //@{ 436117397Skan /** 437117397Skan * @brief Character inserters 438117397Skan * @param out An output stream. 439117397Skan * @param c A character. 440117397Skan * @return out 441117397Skan * 442117397Skan * Behaves like one of the formatted arithmetic inserters described in 443117397Skan * std::basic_ostream. After constructing a sentry object with good 444117397Skan * status, this function inserts a single character and any required 445117397Skan * padding (as determined by [22.2.2.2.2]). @c out.width(0) is then 446117397Skan * called. 447117397Skan * 448117397Skan * If @a c is of type @c char and the character type of the stream is not 449117397Skan * @c char, the character is widened before insertion. 450117397Skan */ 45197403Sobrien template<typename _CharT, typename _Traits> 452169691Skan inline basic_ostream<_CharT, _Traits>& 453169691Skan operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) 454169691Skan { return __ostream_insert(__out, &__c, 1); } 45597403Sobrien 45697403Sobrien template<typename _CharT, typename _Traits> 457169691Skan inline basic_ostream<_CharT, _Traits>& 45897403Sobrien operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) 45997403Sobrien { return (__out << __out.widen(__c)); } 46097403Sobrien 46197403Sobrien // Specialization 46297403Sobrien template <class _Traits> 463169691Skan inline basic_ostream<char, _Traits>& 464169691Skan operator<<(basic_ostream<char, _Traits>& __out, char __c) 465169691Skan { return __ostream_insert(__out, &__c, 1); } 46697403Sobrien 46797403Sobrien // Signed and unsigned 46897403Sobrien template<class _Traits> 469169691Skan inline basic_ostream<char, _Traits>& 47097403Sobrien operator<<(basic_ostream<char, _Traits>& __out, signed char __c) 47197403Sobrien { return (__out << static_cast<char>(__c)); } 47297403Sobrien 47397403Sobrien template<class _Traits> 474169691Skan inline basic_ostream<char, _Traits>& 47597403Sobrien operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) 47697403Sobrien { return (__out << static_cast<char>(__c)); } 477117397Skan //@} 47897403Sobrien 479117397Skan //@{ 480117397Skan /** 481117397Skan * @brief String inserters 482117397Skan * @param out An output stream. 483117397Skan * @param s A character string. 484117397Skan * @return out 485117397Skan * @pre @a s must be a non-NULL pointer 486117397Skan * 487117397Skan * Behaves like one of the formatted arithmetic inserters described in 488117397Skan * std::basic_ostream. After constructing a sentry object with good 489117397Skan * status, this function inserts @c traits::length(s) characters starting 490117397Skan * at @a s, widened if necessary, followed by any required padding (as 491117397Skan * determined by [22.2.2.2.2]). @c out.width(0) is then called. 492117397Skan */ 49397403Sobrien template<typename _CharT, typename _Traits> 494169691Skan inline basic_ostream<_CharT, _Traits>& 495169691Skan operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) 496169691Skan { 497169691Skan if (!__s) 498169691Skan __out.setstate(ios_base::badbit); 499169691Skan else 500169691Skan __ostream_insert(__out, __s, 501169691Skan static_cast<streamsize>(_Traits::length(__s))); 502169691Skan return __out; 503169691Skan } 50497403Sobrien 50597403Sobrien template<typename _CharT, typename _Traits> 50697403Sobrien basic_ostream<_CharT, _Traits> & 50797403Sobrien operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s); 50897403Sobrien 50997403Sobrien // Partial specializationss 51097403Sobrien template<class _Traits> 511169691Skan inline basic_ostream<char, _Traits>& 512169691Skan operator<<(basic_ostream<char, _Traits>& __out, const char* __s) 513169691Skan { 514169691Skan if (!__s) 515169691Skan __out.setstate(ios_base::badbit); 516169691Skan else 517169691Skan __ostream_insert(__out, __s, 518169691Skan static_cast<streamsize>(_Traits::length(__s))); 519169691Skan return __out; 520169691Skan } 521169691Skan 52297403Sobrien // Signed and unsigned 52397403Sobrien template<class _Traits> 524169691Skan inline basic_ostream<char, _Traits>& 52597403Sobrien operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) 52697403Sobrien { return (__out << reinterpret_cast<const char*>(__s)); } 52797403Sobrien 52897403Sobrien template<class _Traits> 529169691Skan inline basic_ostream<char, _Traits> & 53097403Sobrien operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) 53197403Sobrien { return (__out << reinterpret_cast<const char*>(__s)); } 532117397Skan //@} 53397403Sobrien 534117397Skan // [27.6.2.7] standard basic_ostream manipulators 535117397Skan /** 536117397Skan * @brief Write a newline and flush the stream. 537117397Skan * 538117397Skan * This manipulator is often mistakenly used when a simple newline is 539117397Skan * desired, leading to poor buffering performance. See 540117397Skan * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more 541117397Skan * on this subject. 542117397Skan */ 54397403Sobrien template<typename _CharT, typename _Traits> 544169691Skan inline basic_ostream<_CharT, _Traits>& 54597403Sobrien endl(basic_ostream<_CharT, _Traits>& __os) 54697403Sobrien { return flush(__os.put(__os.widen('\n'))); } 54797403Sobrien 548117397Skan /** 549117397Skan * @brief Write a null character into the output sequence. 550117397Skan * 551117397Skan * "Null character" is @c CharT() by definition. For CharT of @c char, 552117397Skan * this correctly writes the ASCII @c NUL character string terminator. 553117397Skan */ 55497403Sobrien template<typename _CharT, typename _Traits> 555169691Skan inline basic_ostream<_CharT, _Traits>& 55697403Sobrien ends(basic_ostream<_CharT, _Traits>& __os) 55797403Sobrien { return __os.put(_CharT()); } 55897403Sobrien 559117397Skan /** 560117397Skan * @brief Flushes the output stream. 561117397Skan * 562117397Skan * This manipulator simply calls the stream's @c flush() member function. 563117397Skan */ 56497403Sobrien template<typename _CharT, typename _Traits> 565169691Skan inline basic_ostream<_CharT, _Traits>& 56697403Sobrien flush(basic_ostream<_CharT, _Traits>& __os) 56797403Sobrien { return __os.flush(); } 56897403Sobrien 569169691Skan_GLIBCXX_END_NAMESPACE 57097403Sobrien 571132720Skan#ifndef _GLIBCXX_EXPORT_TEMPLATE 57297403Sobrien# include <bits/ostream.tcc> 57397403Sobrien#endif 57497403Sobrien 575132720Skan#endif /* _GLIBCXX_OSTREAM */ 576