xref: /aosp_15_r20/external/libcxx/include/ostream (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===-------------------------- ostream -----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_OSTREAM
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_OSTREAM
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    ostream synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> >
18*58b9f456SAndroid Build Coastguard Workerclass basic_ostream
19*58b9f456SAndroid Build Coastguard Worker    : virtual public basic_ios<charT,traits>
20*58b9f456SAndroid Build Coastguard Worker{
21*58b9f456SAndroid Build Coastguard Workerpublic:
22*58b9f456SAndroid Build Coastguard Worker    // types (inherited from basic_ios (27.5.4)):
23*58b9f456SAndroid Build Coastguard Worker    typedef charT                          char_type;
24*58b9f456SAndroid Build Coastguard Worker    typedef traits                         traits_type;
25*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
26*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
27*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.2 Constructor/destructor:
30*58b9f456SAndroid Build Coastguard Worker    explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
31*58b9f456SAndroid Build Coastguard Worker    basic_ostream(basic_ostream&& rhs);
32*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_ostream();
33*58b9f456SAndroid Build Coastguard Worker
34*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.3 Assign/swap
35*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
36*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(basic_ostream&& rhs);
37*58b9f456SAndroid Build Coastguard Worker    void swap(basic_ostream& rhs);
38*58b9f456SAndroid Build Coastguard Worker
39*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.4 Prefix/suffix:
40*58b9f456SAndroid Build Coastguard Worker    class sentry;
41*58b9f456SAndroid Build Coastguard Worker
42*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.6 Formatted output:
43*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
44*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
45*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
46*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(bool n);
47*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(short n);
48*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned short n);
49*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(int n);
50*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned int n);
51*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long n);
52*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned long n);
53*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long long n);
54*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned long long n);
55*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(float f);
56*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(double f);
57*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long double f);
58*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(const void* p);
59*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
60*58b9f456SAndroid Build Coastguard Worker
61*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.7 Unformatted output:
62*58b9f456SAndroid Build Coastguard Worker    basic_ostream& put(char_type c);
63*58b9f456SAndroid Build Coastguard Worker    basic_ostream& write(const char_type* s, streamsize n);
64*58b9f456SAndroid Build Coastguard Worker    basic_ostream& flush();
65*58b9f456SAndroid Build Coastguard Worker
66*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.5 seeks:
67*58b9f456SAndroid Build Coastguard Worker    pos_type tellp();
68*58b9f456SAndroid Build Coastguard Worker    basic_ostream& seekp(pos_type);
69*58b9f456SAndroid Build Coastguard Worker    basic_ostream& seekp(off_type, ios_base::seekdir);
70*58b9f456SAndroid Build Coastguard Workerprotected:
71*58b9f456SAndroid Build Coastguard Worker    basic_ostream(const basic_ostream& rhs) = delete;
72*58b9f456SAndroid Build Coastguard Worker    basic_ostream(basic_ostream&& rhs);
73*58b9f456SAndroid Build Coastguard Worker    // 27.7.3.3 Assign/swap
74*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(basic_ostream& rhs) = delete;
75*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(const basic_ostream&& rhs);
76*58b9f456SAndroid Build Coastguard Worker    void swap(basic_ostream& rhs);
77*58b9f456SAndroid Build Coastguard Worker};
78*58b9f456SAndroid Build Coastguard Worker
79*58b9f456SAndroid Build Coastguard Worker// 27.7.2.6.4 character inserters
80*58b9f456SAndroid Build Coastguard Worker
81*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
82*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
83*58b9f456SAndroid Build Coastguard Worker
84*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
85*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
86*58b9f456SAndroid Build Coastguard Worker
87*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
88*58b9f456SAndroid Build Coastguard Worker  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
89*58b9f456SAndroid Build Coastguard Worker
90*58b9f456SAndroid Build Coastguard Worker// signed and unsigned
91*58b9f456SAndroid Build Coastguard Worker
92*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
93*58b9f456SAndroid Build Coastguard Worker  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
94*58b9f456SAndroid Build Coastguard Worker
95*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
96*58b9f456SAndroid Build Coastguard Worker  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
97*58b9f456SAndroid Build Coastguard Worker
98*58b9f456SAndroid Build Coastguard Worker// NTBS
99*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
100*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
101*58b9f456SAndroid Build Coastguard Worker
102*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
103*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
104*58b9f456SAndroid Build Coastguard Worker
105*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
106*58b9f456SAndroid Build Coastguard Worker  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
107*58b9f456SAndroid Build Coastguard Worker
108*58b9f456SAndroid Build Coastguard Worker// signed and unsigned
109*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
110*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
111*58b9f456SAndroid Build Coastguard Worker
112*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
113*58b9f456SAndroid Build Coastguard Worker  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
114*58b9f456SAndroid Build Coastguard Worker
115*58b9f456SAndroid Build Coastguard Worker// swap:
116*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
117*58b9f456SAndroid Build Coastguard Worker  void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
118*58b9f456SAndroid Build Coastguard Worker
119*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
120*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
121*58b9f456SAndroid Build Coastguard Worker
122*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
123*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
124*58b9f456SAndroid Build Coastguard Worker
125*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
126*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
127*58b9f456SAndroid Build Coastguard Worker
128*58b9f456SAndroid Build Coastguard Worker// rvalue stream insertion
129*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits, class T>
130*58b9f456SAndroid Build Coastguard Worker  basic_ostream<charT, traits>&
131*58b9f456SAndroid Build Coastguard Worker  operator<<(basic_ostream<charT, traits>&& os, const T& x);
132*58b9f456SAndroid Build Coastguard Worker
133*58b9f456SAndroid Build Coastguard Worker}  // std
134*58b9f456SAndroid Build Coastguard Worker
135*58b9f456SAndroid Build Coastguard Worker*/
136*58b9f456SAndroid Build Coastguard Worker
137*58b9f456SAndroid Build Coastguard Worker#include <__config>
138*58b9f456SAndroid Build Coastguard Worker#include <ios>
139*58b9f456SAndroid Build Coastguard Worker#include <streambuf>
140*58b9f456SAndroid Build Coastguard Worker#include <locale>
141*58b9f456SAndroid Build Coastguard Worker#include <iterator>
142*58b9f456SAndroid Build Coastguard Worker#include <bitset>
143*58b9f456SAndroid Build Coastguard Worker#include <version>
144*58b9f456SAndroid Build Coastguard Worker
145*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
147*58b9f456SAndroid Build Coastguard Worker#endif
148*58b9f456SAndroid Build Coastguard Worker
149*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
150*58b9f456SAndroid Build Coastguard Worker
151*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
152*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_ostream
153*58b9f456SAndroid Build Coastguard Worker    : virtual public basic_ios<_CharT, _Traits>
154*58b9f456SAndroid Build Coastguard Worker{
155*58b9f456SAndroid Build Coastguard Workerpublic:
156*58b9f456SAndroid Build Coastguard Worker    // types (inherited from basic_ios (27.5.4)):
157*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                         char_type;
158*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                        traits_type;
159*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
160*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
161*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
162*58b9f456SAndroid Build Coastguard Worker
163*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.2 Constructor/destructor:
164*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
165*58b9f456SAndroid Build Coastguard Worker    explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
166*58b9f456SAndroid Build Coastguard Worker    { this->init(__sb); }
167*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_ostream();
168*58b9f456SAndroid Build Coastguard Workerprotected:
169*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
170*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
171*58b9f456SAndroid Build Coastguard Worker    basic_ostream(basic_ostream&& __rhs);
172*58b9f456SAndroid Build Coastguard Worker
173*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.3 Assign/swap
174*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
175*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(basic_ostream&& __rhs);
176*58b9f456SAndroid Build Coastguard Worker#endif
177*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
178*58b9f456SAndroid Build Coastguard Worker    void swap(basic_ostream& __rhs)
179*58b9f456SAndroid Build Coastguard Worker    { basic_ios<char_type, traits_type>::swap(__rhs); }
180*58b9f456SAndroid Build Coastguard Worker
181*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
182*58b9f456SAndroid Build Coastguard Worker    basic_ostream           (const basic_ostream& __rhs) = delete;
183*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(const basic_ostream& __rhs) = delete;
184*58b9f456SAndroid Build Coastguard Worker#else
185*58b9f456SAndroid Build Coastguard Worker    basic_ostream           (const basic_ostream& __rhs); // not defined
186*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator=(const basic_ostream& __rhs); // not defined
187*58b9f456SAndroid Build Coastguard Worker#endif
188*58b9f456SAndroid Build Coastguard Workerpublic:
189*58b9f456SAndroid Build Coastguard Worker
190*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.4 Prefix/suffix:
191*58b9f456SAndroid Build Coastguard Worker    class _LIBCPP_TEMPLATE_VIS sentry;
192*58b9f456SAndroid Build Coastguard Worker
193*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.6 Formatted output:
194*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
195*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
196*58b9f456SAndroid Build Coastguard Worker    { return __pf(*this); }
197*58b9f456SAndroid Build Coastguard Worker
198*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
199*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_ios<char_type, traits_type>&
200*58b9f456SAndroid Build Coastguard Worker                              (*__pf)(basic_ios<char_type,traits_type>&))
201*58b9f456SAndroid Build Coastguard Worker    { __pf(*this); return *this; }
202*58b9f456SAndroid Build Coastguard Worker
203*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
204*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
205*58b9f456SAndroid Build Coastguard Worker    { __pf(*this); return *this; }
206*58b9f456SAndroid Build Coastguard Worker
207*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(bool __n);
208*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(short __n);
209*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned short __n);
210*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(int __n);
211*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned int __n);
212*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long __n);
213*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned long __n);
214*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long long __n);
215*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(unsigned long long __n);
216*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(float __f);
217*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(double __f);
218*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(long double __f);
219*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(const void* __p);
220*58b9f456SAndroid Build Coastguard Worker    basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
221*58b9f456SAndroid Build Coastguard Worker
222*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.7 Unformatted output:
223*58b9f456SAndroid Build Coastguard Worker    basic_ostream& put(char_type __c);
224*58b9f456SAndroid Build Coastguard Worker    basic_ostream& write(const char_type* __s, streamsize __n);
225*58b9f456SAndroid Build Coastguard Worker    basic_ostream& flush();
226*58b9f456SAndroid Build Coastguard Worker
227*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.5 seeks:
228*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
229*58b9f456SAndroid Build Coastguard Worker    pos_type tellp();
230*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
231*58b9f456SAndroid Build Coastguard Worker    basic_ostream& seekp(pos_type __pos);
232*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
233*58b9f456SAndroid Build Coastguard Worker    basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
234*58b9f456SAndroid Build Coastguard Worker
235*58b9f456SAndroid Build Coastguard Workerprotected:
236*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
237*58b9f456SAndroid Build Coastguard Worker    basic_ostream() {}  // extension, intentially does not initialize
238*58b9f456SAndroid Build Coastguard Worker};
239*58b9f456SAndroid Build Coastguard Worker
240*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
241*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry
242*58b9f456SAndroid Build Coastguard Worker{
243*58b9f456SAndroid Build Coastguard Worker    bool __ok_;
244*58b9f456SAndroid Build Coastguard Worker    basic_ostream<_CharT, _Traits>& __os_;
245*58b9f456SAndroid Build Coastguard Worker
246*58b9f456SAndroid Build Coastguard Worker    sentry(const sentry&); // = delete;
247*58b9f456SAndroid Build Coastguard Worker    sentry& operator=(const sentry&); // = delete;
248*58b9f456SAndroid Build Coastguard Worker
249*58b9f456SAndroid Build Coastguard Workerpublic:
250*58b9f456SAndroid Build Coastguard Worker    explicit sentry(basic_ostream<_CharT, _Traits>& __os);
251*58b9f456SAndroid Build Coastguard Worker    ~sentry();
252*58b9f456SAndroid Build Coastguard Worker
253*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
254*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_EXPLICIT
255*58b9f456SAndroid Build Coastguard Worker        operator bool() const {return __ok_;}
256*58b9f456SAndroid Build Coastguard Worker};
257*58b9f456SAndroid Build Coastguard Worker
258*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
259*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os)
260*58b9f456SAndroid Build Coastguard Worker    : __ok_(false),
261*58b9f456SAndroid Build Coastguard Worker      __os_(__os)
262*58b9f456SAndroid Build Coastguard Worker{
263*58b9f456SAndroid Build Coastguard Worker    if (__os.good())
264*58b9f456SAndroid Build Coastguard Worker    {
265*58b9f456SAndroid Build Coastguard Worker        if (__os.tie())
266*58b9f456SAndroid Build Coastguard Worker            __os.tie()->flush();
267*58b9f456SAndroid Build Coastguard Worker        __ok_ = true;
268*58b9f456SAndroid Build Coastguard Worker    }
269*58b9f456SAndroid Build Coastguard Worker}
270*58b9f456SAndroid Build Coastguard Worker
271*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
272*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::sentry::~sentry()
273*58b9f456SAndroid Build Coastguard Worker{
274*58b9f456SAndroid Build Coastguard Worker    if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf)
275*58b9f456SAndroid Build Coastguard Worker                      && !uncaught_exception())
276*58b9f456SAndroid Build Coastguard Worker    {
277*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
278*58b9f456SAndroid Build Coastguard Worker        try
279*58b9f456SAndroid Build Coastguard Worker        {
280*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
281*58b9f456SAndroid Build Coastguard Worker            if (__os_.rdbuf()->pubsync() == -1)
282*58b9f456SAndroid Build Coastguard Worker                __os_.setstate(ios_base::badbit);
283*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
284*58b9f456SAndroid Build Coastguard Worker        }
285*58b9f456SAndroid Build Coastguard Worker        catch (...)
286*58b9f456SAndroid Build Coastguard Worker        {
287*58b9f456SAndroid Build Coastguard Worker        }
288*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
289*58b9f456SAndroid Build Coastguard Worker    }
290*58b9f456SAndroid Build Coastguard Worker}
291*58b9f456SAndroid Build Coastguard Worker
292*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
293*58b9f456SAndroid Build Coastguard Worker
294*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
295*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
296*58b9f456SAndroid Build Coastguard Worker{
297*58b9f456SAndroid Build Coastguard Worker    this->move(__rhs);
298*58b9f456SAndroid Build Coastguard Worker}
299*58b9f456SAndroid Build Coastguard Worker
300*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
301*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
302*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
303*58b9f456SAndroid Build Coastguard Worker{
304*58b9f456SAndroid Build Coastguard Worker    swap(__rhs);
305*58b9f456SAndroid Build Coastguard Worker    return *this;
306*58b9f456SAndroid Build Coastguard Worker}
307*58b9f456SAndroid Build Coastguard Worker
308*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
309*58b9f456SAndroid Build Coastguard Worker
310*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
311*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::~basic_ostream()
312*58b9f456SAndroid Build Coastguard Worker{
313*58b9f456SAndroid Build Coastguard Worker}
314*58b9f456SAndroid Build Coastguard Worker
315*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
316*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
317*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb)
318*58b9f456SAndroid Build Coastguard Worker{
319*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
320*58b9f456SAndroid Build Coastguard Worker    try
321*58b9f456SAndroid Build Coastguard Worker    {
322*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
323*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
324*58b9f456SAndroid Build Coastguard Worker        if (__s)
325*58b9f456SAndroid Build Coastguard Worker        {
326*58b9f456SAndroid Build Coastguard Worker            if (__sb)
327*58b9f456SAndroid Build Coastguard Worker            {
328*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
329*58b9f456SAndroid Build Coastguard Worker                try
330*58b9f456SAndroid Build Coastguard Worker                {
331*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
332*58b9f456SAndroid Build Coastguard Worker                    typedef istreambuf_iterator<_CharT, _Traits> _Ip;
333*58b9f456SAndroid Build Coastguard Worker                    typedef ostreambuf_iterator<_CharT, _Traits> _Op;
334*58b9f456SAndroid Build Coastguard Worker                    _Ip __i(__sb);
335*58b9f456SAndroid Build Coastguard Worker                    _Ip __eof;
336*58b9f456SAndroid Build Coastguard Worker                    _Op __o(*this);
337*58b9f456SAndroid Build Coastguard Worker                    size_t __c = 0;
338*58b9f456SAndroid Build Coastguard Worker                    for (; __i != __eof; ++__i, ++__o, ++__c)
339*58b9f456SAndroid Build Coastguard Worker                    {
340*58b9f456SAndroid Build Coastguard Worker                        *__o = *__i;
341*58b9f456SAndroid Build Coastguard Worker                        if (__o.failed())
342*58b9f456SAndroid Build Coastguard Worker                            break;
343*58b9f456SAndroid Build Coastguard Worker                    }
344*58b9f456SAndroid Build Coastguard Worker                    if (__c == 0)
345*58b9f456SAndroid Build Coastguard Worker                        this->setstate(ios_base::failbit);
346*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
347*58b9f456SAndroid Build Coastguard Worker                }
348*58b9f456SAndroid Build Coastguard Worker                catch (...)
349*58b9f456SAndroid Build Coastguard Worker                {
350*58b9f456SAndroid Build Coastguard Worker                    this->__set_failbit_and_consider_rethrow();
351*58b9f456SAndroid Build Coastguard Worker                }
352*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
353*58b9f456SAndroid Build Coastguard Worker            }
354*58b9f456SAndroid Build Coastguard Worker            else
355*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
356*58b9f456SAndroid Build Coastguard Worker        }
357*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
358*58b9f456SAndroid Build Coastguard Worker    }
359*58b9f456SAndroid Build Coastguard Worker    catch (...)
360*58b9f456SAndroid Build Coastguard Worker    {
361*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
362*58b9f456SAndroid Build Coastguard Worker    }
363*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
364*58b9f456SAndroid Build Coastguard Worker    return *this;
365*58b9f456SAndroid Build Coastguard Worker}
366*58b9f456SAndroid Build Coastguard Worker
367*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
368*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
369*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(bool __n)
370*58b9f456SAndroid Build Coastguard Worker{
371*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
372*58b9f456SAndroid Build Coastguard Worker    try
373*58b9f456SAndroid Build Coastguard Worker    {
374*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
375*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
376*58b9f456SAndroid Build Coastguard Worker        if (__s)
377*58b9f456SAndroid Build Coastguard Worker        {
378*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
379*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
380*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
381*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
382*58b9f456SAndroid Build Coastguard Worker        }
383*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
384*58b9f456SAndroid Build Coastguard Worker    }
385*58b9f456SAndroid Build Coastguard Worker    catch (...)
386*58b9f456SAndroid Build Coastguard Worker    {
387*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
388*58b9f456SAndroid Build Coastguard Worker    }
389*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
390*58b9f456SAndroid Build Coastguard Worker    return *this;
391*58b9f456SAndroid Build Coastguard Worker}
392*58b9f456SAndroid Build Coastguard Worker
393*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
394*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
395*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(short __n)
396*58b9f456SAndroid Build Coastguard Worker{
397*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
398*58b9f456SAndroid Build Coastguard Worker    try
399*58b9f456SAndroid Build Coastguard Worker    {
400*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
401*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
402*58b9f456SAndroid Build Coastguard Worker        if (__s)
403*58b9f456SAndroid Build Coastguard Worker        {
404*58b9f456SAndroid Build Coastguard Worker            ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
405*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
406*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
407*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(),
408*58b9f456SAndroid Build Coastguard Worker                        __flags == ios_base::oct || __flags == ios_base::hex ?
409*58b9f456SAndroid Build Coastguard Worker                        static_cast<long>(static_cast<unsigned short>(__n))  :
410*58b9f456SAndroid Build Coastguard Worker                        static_cast<long>(__n)).failed())
411*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
412*58b9f456SAndroid Build Coastguard Worker        }
413*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
414*58b9f456SAndroid Build Coastguard Worker    }
415*58b9f456SAndroid Build Coastguard Worker    catch (...)
416*58b9f456SAndroid Build Coastguard Worker    {
417*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
418*58b9f456SAndroid Build Coastguard Worker    }
419*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
420*58b9f456SAndroid Build Coastguard Worker    return *this;
421*58b9f456SAndroid Build Coastguard Worker}
422*58b9f456SAndroid Build Coastguard Worker
423*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
424*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
425*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
426*58b9f456SAndroid Build Coastguard Worker{
427*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
428*58b9f456SAndroid Build Coastguard Worker    try
429*58b9f456SAndroid Build Coastguard Worker    {
430*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
431*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
432*58b9f456SAndroid Build Coastguard Worker        if (__s)
433*58b9f456SAndroid Build Coastguard Worker        {
434*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
435*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
436*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
437*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
438*58b9f456SAndroid Build Coastguard Worker        }
439*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
440*58b9f456SAndroid Build Coastguard Worker    }
441*58b9f456SAndroid Build Coastguard Worker    catch (...)
442*58b9f456SAndroid Build Coastguard Worker    {
443*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
444*58b9f456SAndroid Build Coastguard Worker    }
445*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
446*58b9f456SAndroid Build Coastguard Worker    return *this;
447*58b9f456SAndroid Build Coastguard Worker}
448*58b9f456SAndroid Build Coastguard Worker
449*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
450*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
451*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(int __n)
452*58b9f456SAndroid Build Coastguard Worker{
453*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
454*58b9f456SAndroid Build Coastguard Worker    try
455*58b9f456SAndroid Build Coastguard Worker    {
456*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
457*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
458*58b9f456SAndroid Build Coastguard Worker        if (__s)
459*58b9f456SAndroid Build Coastguard Worker        {
460*58b9f456SAndroid Build Coastguard Worker            ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
461*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
462*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
463*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(),
464*58b9f456SAndroid Build Coastguard Worker                        __flags == ios_base::oct || __flags == ios_base::hex ?
465*58b9f456SAndroid Build Coastguard Worker                        static_cast<long>(static_cast<unsigned int>(__n))  :
466*58b9f456SAndroid Build Coastguard Worker                        static_cast<long>(__n)).failed())
467*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
468*58b9f456SAndroid Build Coastguard Worker        }
469*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
470*58b9f456SAndroid Build Coastguard Worker    }
471*58b9f456SAndroid Build Coastguard Worker    catch (...)
472*58b9f456SAndroid Build Coastguard Worker    {
473*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
474*58b9f456SAndroid Build Coastguard Worker    }
475*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
476*58b9f456SAndroid Build Coastguard Worker    return *this;
477*58b9f456SAndroid Build Coastguard Worker}
478*58b9f456SAndroid Build Coastguard Worker
479*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
480*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
481*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
482*58b9f456SAndroid Build Coastguard Worker{
483*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
484*58b9f456SAndroid Build Coastguard Worker    try
485*58b9f456SAndroid Build Coastguard Worker    {
486*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
487*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
488*58b9f456SAndroid Build Coastguard Worker        if (__s)
489*58b9f456SAndroid Build Coastguard Worker        {
490*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
491*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
492*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
493*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
494*58b9f456SAndroid Build Coastguard Worker        }
495*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
496*58b9f456SAndroid Build Coastguard Worker    }
497*58b9f456SAndroid Build Coastguard Worker    catch (...)
498*58b9f456SAndroid Build Coastguard Worker    {
499*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
500*58b9f456SAndroid Build Coastguard Worker    }
501*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
502*58b9f456SAndroid Build Coastguard Worker    return *this;
503*58b9f456SAndroid Build Coastguard Worker}
504*58b9f456SAndroid Build Coastguard Worker
505*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
506*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
507*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(long __n)
508*58b9f456SAndroid Build Coastguard Worker{
509*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
510*58b9f456SAndroid Build Coastguard Worker    try
511*58b9f456SAndroid Build Coastguard Worker    {
512*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
513*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
514*58b9f456SAndroid Build Coastguard Worker        if (__s)
515*58b9f456SAndroid Build Coastguard Worker        {
516*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
517*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
518*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
519*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
520*58b9f456SAndroid Build Coastguard Worker        }
521*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
522*58b9f456SAndroid Build Coastguard Worker    }
523*58b9f456SAndroid Build Coastguard Worker    catch (...)
524*58b9f456SAndroid Build Coastguard Worker    {
525*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
526*58b9f456SAndroid Build Coastguard Worker    }
527*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
528*58b9f456SAndroid Build Coastguard Worker    return *this;
529*58b9f456SAndroid Build Coastguard Worker}
530*58b9f456SAndroid Build Coastguard Worker
531*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
532*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
533*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
534*58b9f456SAndroid Build Coastguard Worker{
535*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
536*58b9f456SAndroid Build Coastguard Worker    try
537*58b9f456SAndroid Build Coastguard Worker    {
538*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
539*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
540*58b9f456SAndroid Build Coastguard Worker        if (__s)
541*58b9f456SAndroid Build Coastguard Worker        {
542*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
543*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
544*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
545*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
546*58b9f456SAndroid Build Coastguard Worker        }
547*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
548*58b9f456SAndroid Build Coastguard Worker    }
549*58b9f456SAndroid Build Coastguard Worker    catch (...)
550*58b9f456SAndroid Build Coastguard Worker    {
551*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
552*58b9f456SAndroid Build Coastguard Worker    }
553*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
554*58b9f456SAndroid Build Coastguard Worker    return *this;
555*58b9f456SAndroid Build Coastguard Worker}
556*58b9f456SAndroid Build Coastguard Worker
557*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
558*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
559*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(long long __n)
560*58b9f456SAndroid Build Coastguard Worker{
561*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
562*58b9f456SAndroid Build Coastguard Worker    try
563*58b9f456SAndroid Build Coastguard Worker    {
564*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
565*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
566*58b9f456SAndroid Build Coastguard Worker        if (__s)
567*58b9f456SAndroid Build Coastguard Worker        {
568*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
569*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
570*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
571*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
572*58b9f456SAndroid Build Coastguard Worker        }
573*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
574*58b9f456SAndroid Build Coastguard Worker    }
575*58b9f456SAndroid Build Coastguard Worker    catch (...)
576*58b9f456SAndroid Build Coastguard Worker    {
577*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
578*58b9f456SAndroid Build Coastguard Worker    }
579*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
580*58b9f456SAndroid Build Coastguard Worker    return *this;
581*58b9f456SAndroid Build Coastguard Worker}
582*58b9f456SAndroid Build Coastguard Worker
583*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
584*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
585*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
586*58b9f456SAndroid Build Coastguard Worker{
587*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
588*58b9f456SAndroid Build Coastguard Worker    try
589*58b9f456SAndroid Build Coastguard Worker    {
590*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
591*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
592*58b9f456SAndroid Build Coastguard Worker        if (__s)
593*58b9f456SAndroid Build Coastguard Worker        {
594*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
595*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
596*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
597*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
598*58b9f456SAndroid Build Coastguard Worker        }
599*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
600*58b9f456SAndroid Build Coastguard Worker    }
601*58b9f456SAndroid Build Coastguard Worker    catch (...)
602*58b9f456SAndroid Build Coastguard Worker    {
603*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
604*58b9f456SAndroid Build Coastguard Worker    }
605*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
606*58b9f456SAndroid Build Coastguard Worker    return *this;
607*58b9f456SAndroid Build Coastguard Worker}
608*58b9f456SAndroid Build Coastguard Worker
609*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
610*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
611*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(float __n)
612*58b9f456SAndroid Build Coastguard Worker{
613*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
614*58b9f456SAndroid Build Coastguard Worker    try
615*58b9f456SAndroid Build Coastguard Worker    {
616*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
617*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
618*58b9f456SAndroid Build Coastguard Worker        if (__s)
619*58b9f456SAndroid Build Coastguard Worker        {
620*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
621*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
622*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
623*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
624*58b9f456SAndroid Build Coastguard Worker        }
625*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
626*58b9f456SAndroid Build Coastguard Worker    }
627*58b9f456SAndroid Build Coastguard Worker    catch (...)
628*58b9f456SAndroid Build Coastguard Worker    {
629*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
630*58b9f456SAndroid Build Coastguard Worker    }
631*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
632*58b9f456SAndroid Build Coastguard Worker    return *this;
633*58b9f456SAndroid Build Coastguard Worker}
634*58b9f456SAndroid Build Coastguard Worker
635*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
636*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
637*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(double __n)
638*58b9f456SAndroid Build Coastguard Worker{
639*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
640*58b9f456SAndroid Build Coastguard Worker    try
641*58b9f456SAndroid Build Coastguard Worker    {
642*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
643*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
644*58b9f456SAndroid Build Coastguard Worker        if (__s)
645*58b9f456SAndroid Build Coastguard Worker        {
646*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
647*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
648*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
649*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
650*58b9f456SAndroid Build Coastguard Worker        }
651*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
652*58b9f456SAndroid Build Coastguard Worker    }
653*58b9f456SAndroid Build Coastguard Worker    catch (...)
654*58b9f456SAndroid Build Coastguard Worker    {
655*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
656*58b9f456SAndroid Build Coastguard Worker    }
657*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
658*58b9f456SAndroid Build Coastguard Worker    return *this;
659*58b9f456SAndroid Build Coastguard Worker}
660*58b9f456SAndroid Build Coastguard Worker
661*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
662*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
663*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(long double __n)
664*58b9f456SAndroid Build Coastguard Worker{
665*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
666*58b9f456SAndroid Build Coastguard Worker    try
667*58b9f456SAndroid Build Coastguard Worker    {
668*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
669*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
670*58b9f456SAndroid Build Coastguard Worker        if (__s)
671*58b9f456SAndroid Build Coastguard Worker        {
672*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
673*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
674*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
675*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
676*58b9f456SAndroid Build Coastguard Worker        }
677*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
678*58b9f456SAndroid Build Coastguard Worker    }
679*58b9f456SAndroid Build Coastguard Worker    catch (...)
680*58b9f456SAndroid Build Coastguard Worker    {
681*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
682*58b9f456SAndroid Build Coastguard Worker    }
683*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
684*58b9f456SAndroid Build Coastguard Worker    return *this;
685*58b9f456SAndroid Build Coastguard Worker}
686*58b9f456SAndroid Build Coastguard Worker
687*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
688*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
689*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::operator<<(const void* __n)
690*58b9f456SAndroid Build Coastguard Worker{
691*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
692*58b9f456SAndroid Build Coastguard Worker    try
693*58b9f456SAndroid Build Coastguard Worker    {
694*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
695*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
696*58b9f456SAndroid Build Coastguard Worker        if (__s)
697*58b9f456SAndroid Build Coastguard Worker        {
698*58b9f456SAndroid Build Coastguard Worker            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
699*58b9f456SAndroid Build Coastguard Worker            const _Fp& __f = use_facet<_Fp>(this->getloc());
700*58b9f456SAndroid Build Coastguard Worker            if (__f.put(*this, *this, this->fill(), __n).failed())
701*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit | ios_base::failbit);
702*58b9f456SAndroid Build Coastguard Worker        }
703*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
704*58b9f456SAndroid Build Coastguard Worker    }
705*58b9f456SAndroid Build Coastguard Worker    catch (...)
706*58b9f456SAndroid Build Coastguard Worker    {
707*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
708*58b9f456SAndroid Build Coastguard Worker    }
709*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
710*58b9f456SAndroid Build Coastguard Worker    return *this;
711*58b9f456SAndroid Build Coastguard Worker}
712*58b9f456SAndroid Build Coastguard Worker
713*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
714*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
715*58b9f456SAndroid Build Coastguard Worker__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
716*58b9f456SAndroid Build Coastguard Worker                          const _CharT* __str, size_t __len)
717*58b9f456SAndroid Build Coastguard Worker{
718*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
719*58b9f456SAndroid Build Coastguard Worker    try
720*58b9f456SAndroid Build Coastguard Worker    {
721*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
722*58b9f456SAndroid Build Coastguard Worker        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
723*58b9f456SAndroid Build Coastguard Worker        if (__s)
724*58b9f456SAndroid Build Coastguard Worker        {
725*58b9f456SAndroid Build Coastguard Worker            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
726*58b9f456SAndroid Build Coastguard Worker            if (__pad_and_output(_Ip(__os),
727*58b9f456SAndroid Build Coastguard Worker                                 __str,
728*58b9f456SAndroid Build Coastguard Worker                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
729*58b9f456SAndroid Build Coastguard Worker                                     __str + __len :
730*58b9f456SAndroid Build Coastguard Worker                                     __str,
731*58b9f456SAndroid Build Coastguard Worker                                 __str + __len,
732*58b9f456SAndroid Build Coastguard Worker                                 __os,
733*58b9f456SAndroid Build Coastguard Worker                                 __os.fill()).failed())
734*58b9f456SAndroid Build Coastguard Worker                __os.setstate(ios_base::badbit | ios_base::failbit);
735*58b9f456SAndroid Build Coastguard Worker        }
736*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
737*58b9f456SAndroid Build Coastguard Worker    }
738*58b9f456SAndroid Build Coastguard Worker    catch (...)
739*58b9f456SAndroid Build Coastguard Worker    {
740*58b9f456SAndroid Build Coastguard Worker        __os.__set_badbit_and_consider_rethrow();
741*58b9f456SAndroid Build Coastguard Worker    }
742*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
743*58b9f456SAndroid Build Coastguard Worker    return __os;
744*58b9f456SAndroid Build Coastguard Worker}
745*58b9f456SAndroid Build Coastguard Worker
746*58b9f456SAndroid Build Coastguard Worker
747*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
748*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
749*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
750*58b9f456SAndroid Build Coastguard Worker{
751*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, &__c, 1);
752*58b9f456SAndroid Build Coastguard Worker}
753*58b9f456SAndroid Build Coastguard Worker
754*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
755*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
756*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
757*58b9f456SAndroid Build Coastguard Worker{
758*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
759*58b9f456SAndroid Build Coastguard Worker    try
760*58b9f456SAndroid Build Coastguard Worker    {
761*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
762*58b9f456SAndroid Build Coastguard Worker        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
763*58b9f456SAndroid Build Coastguard Worker        if (__s)
764*58b9f456SAndroid Build Coastguard Worker        {
765*58b9f456SAndroid Build Coastguard Worker            _CharT __c = __os.widen(__cn);
766*58b9f456SAndroid Build Coastguard Worker            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
767*58b9f456SAndroid Build Coastguard Worker            if (__pad_and_output(_Ip(__os),
768*58b9f456SAndroid Build Coastguard Worker                                 &__c,
769*58b9f456SAndroid Build Coastguard Worker                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
770*58b9f456SAndroid Build Coastguard Worker                                     &__c + 1 :
771*58b9f456SAndroid Build Coastguard Worker                                     &__c,
772*58b9f456SAndroid Build Coastguard Worker                                 &__c + 1,
773*58b9f456SAndroid Build Coastguard Worker                                 __os,
774*58b9f456SAndroid Build Coastguard Worker                                 __os.fill()).failed())
775*58b9f456SAndroid Build Coastguard Worker                __os.setstate(ios_base::badbit | ios_base::failbit);
776*58b9f456SAndroid Build Coastguard Worker        }
777*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
778*58b9f456SAndroid Build Coastguard Worker    }
779*58b9f456SAndroid Build Coastguard Worker    catch (...)
780*58b9f456SAndroid Build Coastguard Worker    {
781*58b9f456SAndroid Build Coastguard Worker        __os.__set_badbit_and_consider_rethrow();
782*58b9f456SAndroid Build Coastguard Worker    }
783*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
784*58b9f456SAndroid Build Coastguard Worker    return __os;
785*58b9f456SAndroid Build Coastguard Worker}
786*58b9f456SAndroid Build Coastguard Worker
787*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
788*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
789*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, char __c)
790*58b9f456SAndroid Build Coastguard Worker{
791*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, &__c, 1);
792*58b9f456SAndroid Build Coastguard Worker}
793*58b9f456SAndroid Build Coastguard Worker
794*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
795*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
796*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, signed char __c)
797*58b9f456SAndroid Build Coastguard Worker{
798*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
799*58b9f456SAndroid Build Coastguard Worker}
800*58b9f456SAndroid Build Coastguard Worker
801*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
802*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
803*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
804*58b9f456SAndroid Build Coastguard Worker{
805*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
806*58b9f456SAndroid Build Coastguard Worker}
807*58b9f456SAndroid Build Coastguard Worker
808*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
809*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
810*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
811*58b9f456SAndroid Build Coastguard Worker{
812*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
813*58b9f456SAndroid Build Coastguard Worker}
814*58b9f456SAndroid Build Coastguard Worker
815*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
816*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
817*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
818*58b9f456SAndroid Build Coastguard Worker{
819*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
820*58b9f456SAndroid Build Coastguard Worker    try
821*58b9f456SAndroid Build Coastguard Worker    {
822*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
823*58b9f456SAndroid Build Coastguard Worker        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
824*58b9f456SAndroid Build Coastguard Worker        if (__s)
825*58b9f456SAndroid Build Coastguard Worker        {
826*58b9f456SAndroid Build Coastguard Worker            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
827*58b9f456SAndroid Build Coastguard Worker            size_t __len = char_traits<char>::length(__strn);
828*58b9f456SAndroid Build Coastguard Worker            const int __bs = 100;
829*58b9f456SAndroid Build Coastguard Worker            _CharT __wbb[__bs];
830*58b9f456SAndroid Build Coastguard Worker            _CharT* __wb = __wbb;
831*58b9f456SAndroid Build Coastguard Worker            unique_ptr<_CharT, void(*)(void*)> __h(0, free);
832*58b9f456SAndroid Build Coastguard Worker            if (__len > __bs)
833*58b9f456SAndroid Build Coastguard Worker            {
834*58b9f456SAndroid Build Coastguard Worker                __wb = (_CharT*)malloc(__len*sizeof(_CharT));
835*58b9f456SAndroid Build Coastguard Worker                if (__wb == 0)
836*58b9f456SAndroid Build Coastguard Worker                    __throw_bad_alloc();
837*58b9f456SAndroid Build Coastguard Worker                __h.reset(__wb);
838*58b9f456SAndroid Build Coastguard Worker            }
839*58b9f456SAndroid Build Coastguard Worker            for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
840*58b9f456SAndroid Build Coastguard Worker                *__p = __os.widen(*__strn);
841*58b9f456SAndroid Build Coastguard Worker            if (__pad_and_output(_Ip(__os),
842*58b9f456SAndroid Build Coastguard Worker                                 __wb,
843*58b9f456SAndroid Build Coastguard Worker                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
844*58b9f456SAndroid Build Coastguard Worker                                     __wb + __len :
845*58b9f456SAndroid Build Coastguard Worker                                     __wb,
846*58b9f456SAndroid Build Coastguard Worker                                 __wb + __len,
847*58b9f456SAndroid Build Coastguard Worker                                 __os,
848*58b9f456SAndroid Build Coastguard Worker                                 __os.fill()).failed())
849*58b9f456SAndroid Build Coastguard Worker                __os.setstate(ios_base::badbit | ios_base::failbit);
850*58b9f456SAndroid Build Coastguard Worker        }
851*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
852*58b9f456SAndroid Build Coastguard Worker    }
853*58b9f456SAndroid Build Coastguard Worker    catch (...)
854*58b9f456SAndroid Build Coastguard Worker    {
855*58b9f456SAndroid Build Coastguard Worker        __os.__set_badbit_and_consider_rethrow();
856*58b9f456SAndroid Build Coastguard Worker    }
857*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
858*58b9f456SAndroid Build Coastguard Worker    return __os;
859*58b9f456SAndroid Build Coastguard Worker}
860*58b9f456SAndroid Build Coastguard Worker
861*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
862*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
863*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, const char* __str)
864*58b9f456SAndroid Build Coastguard Worker{
865*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
866*58b9f456SAndroid Build Coastguard Worker}
867*58b9f456SAndroid Build Coastguard Worker
868*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
869*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
870*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
871*58b9f456SAndroid Build Coastguard Worker{
872*58b9f456SAndroid Build Coastguard Worker    const char *__s = (const char *) __str;
873*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
874*58b9f456SAndroid Build Coastguard Worker}
875*58b9f456SAndroid Build Coastguard Worker
876*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
877*58b9f456SAndroid Build Coastguard Workerbasic_ostream<char, _Traits>&
878*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
879*58b9f456SAndroid Build Coastguard Worker{
880*58b9f456SAndroid Build Coastguard Worker    const char *__s = (const char *) __str;
881*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
882*58b9f456SAndroid Build Coastguard Worker}
883*58b9f456SAndroid Build Coastguard Worker
884*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
885*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
886*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::put(char_type __c)
887*58b9f456SAndroid Build Coastguard Worker{
888*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
889*58b9f456SAndroid Build Coastguard Worker    try
890*58b9f456SAndroid Build Coastguard Worker    {
891*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
892*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this);
893*58b9f456SAndroid Build Coastguard Worker        if (__s)
894*58b9f456SAndroid Build Coastguard Worker        {
895*58b9f456SAndroid Build Coastguard Worker            typedef ostreambuf_iterator<_CharT, _Traits> _Op;
896*58b9f456SAndroid Build Coastguard Worker            _Op __o(*this);
897*58b9f456SAndroid Build Coastguard Worker            *__o = __c;
898*58b9f456SAndroid Build Coastguard Worker            if (__o.failed())
899*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
900*58b9f456SAndroid Build Coastguard Worker        }
901*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
902*58b9f456SAndroid Build Coastguard Worker    }
903*58b9f456SAndroid Build Coastguard Worker    catch (...)
904*58b9f456SAndroid Build Coastguard Worker    {
905*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
906*58b9f456SAndroid Build Coastguard Worker    }
907*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
908*58b9f456SAndroid Build Coastguard Worker    return *this;
909*58b9f456SAndroid Build Coastguard Worker}
910*58b9f456SAndroid Build Coastguard Worker
911*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
912*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
913*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
914*58b9f456SAndroid Build Coastguard Worker{
915*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
916*58b9f456SAndroid Build Coastguard Worker    try
917*58b9f456SAndroid Build Coastguard Worker    {
918*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
919*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this);
920*58b9f456SAndroid Build Coastguard Worker        if (__sen && __n)
921*58b9f456SAndroid Build Coastguard Worker        {
922*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf()->sputn(__s, __n) != __n)
923*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
924*58b9f456SAndroid Build Coastguard Worker        }
925*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
926*58b9f456SAndroid Build Coastguard Worker    }
927*58b9f456SAndroid Build Coastguard Worker    catch (...)
928*58b9f456SAndroid Build Coastguard Worker    {
929*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
930*58b9f456SAndroid Build Coastguard Worker    }
931*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
932*58b9f456SAndroid Build Coastguard Worker    return *this;
933*58b9f456SAndroid Build Coastguard Worker}
934*58b9f456SAndroid Build Coastguard Worker
935*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
936*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
937*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::flush()
938*58b9f456SAndroid Build Coastguard Worker{
939*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
940*58b9f456SAndroid Build Coastguard Worker    try
941*58b9f456SAndroid Build Coastguard Worker    {
942*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
943*58b9f456SAndroid Build Coastguard Worker        if (this->rdbuf())
944*58b9f456SAndroid Build Coastguard Worker        {
945*58b9f456SAndroid Build Coastguard Worker            sentry __s(*this);
946*58b9f456SAndroid Build Coastguard Worker            if (__s)
947*58b9f456SAndroid Build Coastguard Worker            {
948*58b9f456SAndroid Build Coastguard Worker                if (this->rdbuf()->pubsync() == -1)
949*58b9f456SAndroid Build Coastguard Worker                    this->setstate(ios_base::badbit);
950*58b9f456SAndroid Build Coastguard Worker            }
951*58b9f456SAndroid Build Coastguard Worker        }
952*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
953*58b9f456SAndroid Build Coastguard Worker    }
954*58b9f456SAndroid Build Coastguard Worker    catch (...)
955*58b9f456SAndroid Build Coastguard Worker    {
956*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
957*58b9f456SAndroid Build Coastguard Worker    }
958*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
959*58b9f456SAndroid Build Coastguard Worker    return *this;
960*58b9f456SAndroid Build Coastguard Worker}
961*58b9f456SAndroid Build Coastguard Worker
962*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
963*58b9f456SAndroid Build Coastguard Workertypename basic_ostream<_CharT, _Traits>::pos_type
964*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::tellp()
965*58b9f456SAndroid Build Coastguard Worker{
966*58b9f456SAndroid Build Coastguard Worker    if (this->fail())
967*58b9f456SAndroid Build Coastguard Worker        return pos_type(-1);
968*58b9f456SAndroid Build Coastguard Worker    return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
969*58b9f456SAndroid Build Coastguard Worker}
970*58b9f456SAndroid Build Coastguard Worker
971*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
972*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
973*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
974*58b9f456SAndroid Build Coastguard Worker{
975*58b9f456SAndroid Build Coastguard Worker    sentry __s(*this);
976*58b9f456SAndroid Build Coastguard Worker    if (!this->fail())
977*58b9f456SAndroid Build Coastguard Worker    {
978*58b9f456SAndroid Build Coastguard Worker        if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
979*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
980*58b9f456SAndroid Build Coastguard Worker    }
981*58b9f456SAndroid Build Coastguard Worker    return *this;
982*58b9f456SAndroid Build Coastguard Worker}
983*58b9f456SAndroid Build Coastguard Worker
984*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
985*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
986*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
987*58b9f456SAndroid Build Coastguard Worker{
988*58b9f456SAndroid Build Coastguard Worker    sentry __s(*this);
989*58b9f456SAndroid Build Coastguard Worker    if (!this->fail())
990*58b9f456SAndroid Build Coastguard Worker    {
991*58b9f456SAndroid Build Coastguard Worker        if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
992*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
993*58b9f456SAndroid Build Coastguard Worker    }
994*58b9f456SAndroid Build Coastguard Worker    return *this;
995*58b9f456SAndroid Build Coastguard Worker}
996*58b9f456SAndroid Build Coastguard Worker
997*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
998*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
999*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1000*58b9f456SAndroid Build Coastguard Workerendl(basic_ostream<_CharT, _Traits>& __os)
1001*58b9f456SAndroid Build Coastguard Worker{
1002*58b9f456SAndroid Build Coastguard Worker    __os.put(__os.widen('\n'));
1003*58b9f456SAndroid Build Coastguard Worker    __os.flush();
1004*58b9f456SAndroid Build Coastguard Worker    return __os;
1005*58b9f456SAndroid Build Coastguard Worker}
1006*58b9f456SAndroid Build Coastguard Worker
1007*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1008*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1009*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1010*58b9f456SAndroid Build Coastguard Workerends(basic_ostream<_CharT, _Traits>& __os)
1011*58b9f456SAndroid Build Coastguard Worker{
1012*58b9f456SAndroid Build Coastguard Worker    __os.put(_CharT());
1013*58b9f456SAndroid Build Coastguard Worker    return __os;
1014*58b9f456SAndroid Build Coastguard Worker}
1015*58b9f456SAndroid Build Coastguard Worker
1016*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1017*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1018*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1019*58b9f456SAndroid Build Coastguard Workerflush(basic_ostream<_CharT, _Traits>& __os)
1020*58b9f456SAndroid Build Coastguard Worker{
1021*58b9f456SAndroid Build Coastguard Worker    __os.flush();
1022*58b9f456SAndroid Build Coastguard Worker    return __os;
1023*58b9f456SAndroid Build Coastguard Worker}
1024*58b9f456SAndroid Build Coastguard Worker
1025*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1026*58b9f456SAndroid Build Coastguard Worker
1027*58b9f456SAndroid Build Coastguard Workertemplate <class _Stream, class _Tp>
1028*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1029*58b9f456SAndroid Build Coastguard Workertypename enable_if
1030*58b9f456SAndroid Build Coastguard Worker<
1031*58b9f456SAndroid Build Coastguard Worker    !is_lvalue_reference<_Stream>::value &&
1032*58b9f456SAndroid Build Coastguard Worker    is_base_of<ios_base, _Stream>::value,
1033*58b9f456SAndroid Build Coastguard Worker    _Stream&&
1034*58b9f456SAndroid Build Coastguard Worker>::type
1035*58b9f456SAndroid Build Coastguard Workeroperator<<(_Stream&& __os, const _Tp& __x)
1036*58b9f456SAndroid Build Coastguard Worker{
1037*58b9f456SAndroid Build Coastguard Worker    __os << __x;
1038*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__os);
1039*58b9f456SAndroid Build Coastguard Worker}
1040*58b9f456SAndroid Build Coastguard Worker
1041*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1042*58b9f456SAndroid Build Coastguard Worker
1043*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1044*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1045*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os,
1046*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __str)
1047*58b9f456SAndroid Build Coastguard Worker{
1048*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
1049*58b9f456SAndroid Build Coastguard Worker}
1050*58b9f456SAndroid Build Coastguard Worker
1051*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1052*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1053*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os,
1054*58b9f456SAndroid Build Coastguard Worker           const basic_string_view<_CharT, _Traits> __sv)
1055*58b9f456SAndroid Build Coastguard Worker{
1056*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
1057*58b9f456SAndroid Build Coastguard Worker}
1058*58b9f456SAndroid Build Coastguard Worker
1059*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1060*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1061*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1062*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
1063*58b9f456SAndroid Build Coastguard Worker{
1064*58b9f456SAndroid Build Coastguard Worker    return __os << __ec.category().name() << ':' << __ec.value();
1065*58b9f456SAndroid Build Coastguard Worker}
1066*58b9f456SAndroid Build Coastguard Worker
1067*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Yp>
1068*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1069*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1070*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
1071*58b9f456SAndroid Build Coastguard Worker{
1072*58b9f456SAndroid Build Coastguard Worker    return __os << __p.get();
1073*58b9f456SAndroid Build Coastguard Worker}
1074*58b9f456SAndroid Build Coastguard Worker
1075*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Yp, class _Dp>
1076*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1077*58b9f456SAndroid Build Coastguard Workertypename enable_if
1078*58b9f456SAndroid Build Coastguard Worker<
1079*58b9f456SAndroid Build Coastguard Worker    is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value,
1080*58b9f456SAndroid Build Coastguard Worker    basic_ostream<_CharT, _Traits>&
1081*58b9f456SAndroid Build Coastguard Worker>::type
1082*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
1083*58b9f456SAndroid Build Coastguard Worker{
1084*58b9f456SAndroid Build Coastguard Worker    return __os << __p.get();
1085*58b9f456SAndroid Build Coastguard Worker}
1086*58b9f456SAndroid Build Coastguard Worker
1087*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, size_t _Size>
1088*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
1089*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
1090*58b9f456SAndroid Build Coastguard Worker{
1091*58b9f456SAndroid Build Coastguard Worker    return __os << __x.template to_string<_CharT, _Traits>
1092*58b9f456SAndroid Build Coastguard Worker                        (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
1093*58b9f456SAndroid Build Coastguard Worker                         use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
1094*58b9f456SAndroid Build Coastguard Worker}
1095*58b9f456SAndroid Build Coastguard Worker
1096*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1097*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
1098*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
1099*58b9f456SAndroid Build Coastguard Worker#endif
1100*58b9f456SAndroid Build Coastguard Worker
1101*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
1102*58b9f456SAndroid Build Coastguard Worker
1103*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_OSTREAM
1104