1*c303c47eSjoerg// -*- C++ -*-
2*c303c47eSjoerg//===---------------------------- ios -------------------------------------===//
3*c303c47eSjoerg//
4*c303c47eSjoerg// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*c303c47eSjoerg// See https://llvm.org/LICENSE.txt for license information.
6*c303c47eSjoerg// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*c303c47eSjoerg//
8*c303c47eSjoerg//===----------------------------------------------------------------------===//
9*c303c47eSjoerg
10*c303c47eSjoerg#ifndef _LIBCPP_IOS
11*c303c47eSjoerg#define _LIBCPP_IOS
12*c303c47eSjoerg
13*c303c47eSjoerg/*
14*c303c47eSjoerg    ios synopsis
15*c303c47eSjoerg
16*c303c47eSjoerg#include <iosfwd>
17*c303c47eSjoerg
18*c303c47eSjoergnamespace std
19*c303c47eSjoerg{
20*c303c47eSjoerg
21*c303c47eSjoergtypedef OFF_T streamoff;
22*c303c47eSjoergtypedef SZ_T streamsize;
23*c303c47eSjoergtemplate <class stateT> class fpos;
24*c303c47eSjoerg
25*c303c47eSjoergclass ios_base
26*c303c47eSjoerg{
27*c303c47eSjoergpublic:
28*c303c47eSjoerg    class failure;
29*c303c47eSjoerg
30*c303c47eSjoerg    typedef T1 fmtflags;
31*c303c47eSjoerg    static constexpr fmtflags boolalpha;
32*c303c47eSjoerg    static constexpr fmtflags dec;
33*c303c47eSjoerg    static constexpr fmtflags fixed;
34*c303c47eSjoerg    static constexpr fmtflags hex;
35*c303c47eSjoerg    static constexpr fmtflags internal;
36*c303c47eSjoerg    static constexpr fmtflags left;
37*c303c47eSjoerg    static constexpr fmtflags oct;
38*c303c47eSjoerg    static constexpr fmtflags right;
39*c303c47eSjoerg    static constexpr fmtflags scientific;
40*c303c47eSjoerg    static constexpr fmtflags showbase;
41*c303c47eSjoerg    static constexpr fmtflags showpoint;
42*c303c47eSjoerg    static constexpr fmtflags showpos;
43*c303c47eSjoerg    static constexpr fmtflags skipws;
44*c303c47eSjoerg    static constexpr fmtflags unitbuf;
45*c303c47eSjoerg    static constexpr fmtflags uppercase;
46*c303c47eSjoerg    static constexpr fmtflags adjustfield;
47*c303c47eSjoerg    static constexpr fmtflags basefield;
48*c303c47eSjoerg    static constexpr fmtflags floatfield;
49*c303c47eSjoerg
50*c303c47eSjoerg    typedef T2 iostate;
51*c303c47eSjoerg    static constexpr iostate badbit;
52*c303c47eSjoerg    static constexpr iostate eofbit;
53*c303c47eSjoerg    static constexpr iostate failbit;
54*c303c47eSjoerg    static constexpr iostate goodbit;
55*c303c47eSjoerg
56*c303c47eSjoerg    typedef T3 openmode;
57*c303c47eSjoerg    static constexpr openmode app;
58*c303c47eSjoerg    static constexpr openmode ate;
59*c303c47eSjoerg    static constexpr openmode binary;
60*c303c47eSjoerg    static constexpr openmode in;
61*c303c47eSjoerg    static constexpr openmode out;
62*c303c47eSjoerg    static constexpr openmode trunc;
63*c303c47eSjoerg
64*c303c47eSjoerg    typedef T4 seekdir;
65*c303c47eSjoerg    static constexpr seekdir beg;
66*c303c47eSjoerg    static constexpr seekdir cur;
67*c303c47eSjoerg    static constexpr seekdir end;
68*c303c47eSjoerg
69*c303c47eSjoerg    class Init;
70*c303c47eSjoerg
71*c303c47eSjoerg    // 27.5.2.2 fmtflags state:
72*c303c47eSjoerg    fmtflags flags() const;
73*c303c47eSjoerg    fmtflags flags(fmtflags fmtfl);
74*c303c47eSjoerg    fmtflags setf(fmtflags fmtfl);
75*c303c47eSjoerg    fmtflags setf(fmtflags fmtfl, fmtflags mask);
76*c303c47eSjoerg    void unsetf(fmtflags mask);
77*c303c47eSjoerg
78*c303c47eSjoerg    streamsize precision() const;
79*c303c47eSjoerg    streamsize precision(streamsize prec);
80*c303c47eSjoerg    streamsize width() const;
81*c303c47eSjoerg    streamsize width(streamsize wide);
82*c303c47eSjoerg
83*c303c47eSjoerg    // 27.5.2.3 locales:
84*c303c47eSjoerg    locale imbue(const locale& loc);
85*c303c47eSjoerg    locale getloc() const;
86*c303c47eSjoerg
87*c303c47eSjoerg    // 27.5.2.5 storage:
88*c303c47eSjoerg    static int xalloc();
89*c303c47eSjoerg    long& iword(int index);
90*c303c47eSjoerg    void*& pword(int index);
91*c303c47eSjoerg
92*c303c47eSjoerg    // destructor
93*c303c47eSjoerg    virtual ~ios_base();
94*c303c47eSjoerg
95*c303c47eSjoerg    // 27.5.2.6 callbacks;
96*c303c47eSjoerg    enum event { erase_event, imbue_event, copyfmt_event };
97*c303c47eSjoerg    typedef void (*event_callback)(event, ios_base&, int index);
98*c303c47eSjoerg    void register_callback(event_callback fn, int index);
99*c303c47eSjoerg
100*c303c47eSjoerg    ios_base(const ios_base&) = delete;
101*c303c47eSjoerg    ios_base& operator=(const ios_base&) = delete;
102*c303c47eSjoerg
103*c303c47eSjoerg    static bool sync_with_stdio(bool sync = true);
104*c303c47eSjoerg
105*c303c47eSjoergprotected:
106*c303c47eSjoerg    ios_base();
107*c303c47eSjoerg};
108*c303c47eSjoerg
109*c303c47eSjoergtemplate <class charT, class traits = char_traits<charT> >
110*c303c47eSjoergclass basic_ios
111*c303c47eSjoerg    : public ios_base
112*c303c47eSjoerg{
113*c303c47eSjoergpublic:
114*c303c47eSjoerg    // types:
115*c303c47eSjoerg    typedef charT char_type;
116*c303c47eSjoerg    typedef typename traits::int_type int_type;  // removed in C++17
117*c303c47eSjoerg    typedef typename traits::pos_type pos_type;  // removed in C++17
118*c303c47eSjoerg    typedef typename traits::off_type off_type;  // removed in C++17
119*c303c47eSjoerg    typedef traits traits_type;
120*c303c47eSjoerg
121*c303c47eSjoerg    operator unspecified-bool-type() const;
122*c303c47eSjoerg    bool operator!() const;
123*c303c47eSjoerg    iostate rdstate() const;
124*c303c47eSjoerg    void clear(iostate state = goodbit);
125*c303c47eSjoerg    void setstate(iostate state);
126*c303c47eSjoerg    bool good() const;
127*c303c47eSjoerg    bool eof() const;
128*c303c47eSjoerg    bool fail() const;
129*c303c47eSjoerg    bool bad() const;
130*c303c47eSjoerg
131*c303c47eSjoerg    iostate exceptions() const;
132*c303c47eSjoerg    void exceptions(iostate except);
133*c303c47eSjoerg
134*c303c47eSjoerg    // 27.5.4.1 Constructor/destructor:
135*c303c47eSjoerg    explicit basic_ios(basic_streambuf<charT,traits>* sb);
136*c303c47eSjoerg    virtual ~basic_ios();
137*c303c47eSjoerg
138*c303c47eSjoerg    // 27.5.4.2 Members:
139*c303c47eSjoerg    basic_ostream<charT,traits>* tie() const;
140*c303c47eSjoerg    basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
141*c303c47eSjoerg
142*c303c47eSjoerg    basic_streambuf<charT,traits>* rdbuf() const;
143*c303c47eSjoerg    basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
144*c303c47eSjoerg
145*c303c47eSjoerg    basic_ios& copyfmt(const basic_ios& rhs);
146*c303c47eSjoerg
147*c303c47eSjoerg    char_type fill() const;
148*c303c47eSjoerg    char_type fill(char_type ch);
149*c303c47eSjoerg
150*c303c47eSjoerg    locale imbue(const locale& loc);
151*c303c47eSjoerg
152*c303c47eSjoerg    char narrow(char_type c, char dfault) const;
153*c303c47eSjoerg    char_type widen(char c) const;
154*c303c47eSjoerg
155*c303c47eSjoerg    basic_ios(const basic_ios& ) = delete;
156*c303c47eSjoerg    basic_ios& operator=(const basic_ios&) = delete;
157*c303c47eSjoerg
158*c303c47eSjoergprotected:
159*c303c47eSjoerg    basic_ios();
160*c303c47eSjoerg    void init(basic_streambuf<charT,traits>* sb);
161*c303c47eSjoerg    void move(basic_ios& rhs);
162*c303c47eSjoerg    void swap(basic_ios& rhs) noexcept;
163*c303c47eSjoerg    void set_rdbuf(basic_streambuf<charT, traits>* sb);
164*c303c47eSjoerg};
165*c303c47eSjoerg
166*c303c47eSjoerg// 27.5.5, manipulators:
167*c303c47eSjoergios_base& boolalpha (ios_base& str);
168*c303c47eSjoergios_base& noboolalpha(ios_base& str);
169*c303c47eSjoergios_base& showbase (ios_base& str);
170*c303c47eSjoergios_base& noshowbase (ios_base& str);
171*c303c47eSjoergios_base& showpoint (ios_base& str);
172*c303c47eSjoergios_base& noshowpoint(ios_base& str);
173*c303c47eSjoergios_base& showpos (ios_base& str);
174*c303c47eSjoergios_base& noshowpos (ios_base& str);
175*c303c47eSjoergios_base& skipws (ios_base& str);
176*c303c47eSjoergios_base& noskipws (ios_base& str);
177*c303c47eSjoergios_base& uppercase (ios_base& str);
178*c303c47eSjoergios_base& nouppercase(ios_base& str);
179*c303c47eSjoergios_base& unitbuf (ios_base& str);
180*c303c47eSjoergios_base& nounitbuf (ios_base& str);
181*c303c47eSjoerg
182*c303c47eSjoerg// 27.5.5.2 adjustfield:
183*c303c47eSjoergios_base& internal (ios_base& str);
184*c303c47eSjoergios_base& left (ios_base& str);
185*c303c47eSjoergios_base& right (ios_base& str);
186*c303c47eSjoerg
187*c303c47eSjoerg// 27.5.5.3 basefield:
188*c303c47eSjoergios_base& dec (ios_base& str);
189*c303c47eSjoergios_base& hex (ios_base& str);
190*c303c47eSjoergios_base& oct (ios_base& str);
191*c303c47eSjoerg
192*c303c47eSjoerg// 27.5.5.4 floatfield:
193*c303c47eSjoergios_base& fixed (ios_base& str);
194*c303c47eSjoergios_base& scientific (ios_base& str);
195*c303c47eSjoergios_base& hexfloat (ios_base& str);
196*c303c47eSjoergios_base& defaultfloat(ios_base& str);
197*c303c47eSjoerg
198*c303c47eSjoerg// 27.5.5.5 error reporting:
199*c303c47eSjoergenum class io_errc
200*c303c47eSjoerg{
201*c303c47eSjoerg    stream = 1
202*c303c47eSjoerg};
203*c303c47eSjoerg
204*c303c47eSjoergconcept_map ErrorCodeEnum<io_errc> { };
205*c303c47eSjoergerror_code make_error_code(io_errc e) noexcept;
206*c303c47eSjoergerror_condition make_error_condition(io_errc e) noexcept;
207*c303c47eSjoergstorage-class-specifier const error_category& iostream_category() noexcept;
208*c303c47eSjoerg
209*c303c47eSjoerg}  // std
210*c303c47eSjoerg
211*c303c47eSjoerg*/
212*c303c47eSjoerg
213*c303c47eSjoerg#include <__config>
214*c303c47eSjoerg#include <iosfwd>
215*c303c47eSjoerg#include <__locale>
216*c303c47eSjoerg#include <system_error>
217*c303c47eSjoerg
218*c303c47eSjoerg#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
219*c303c47eSjoerg#include <atomic>     // for __xindex_
220*c303c47eSjoerg#endif
221*c303c47eSjoerg
222*c303c47eSjoerg#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
223*c303c47eSjoerg#pragma GCC system_header
224*c303c47eSjoerg#endif
225*c303c47eSjoerg
226*c303c47eSjoerg_LIBCPP_BEGIN_NAMESPACE_STD
227*c303c47eSjoerg
228*c303c47eSjoergtypedef ptrdiff_t streamsize;
229*c303c47eSjoerg
230*c303c47eSjoergclass _LIBCPP_TYPE_VIS ios_base
231*c303c47eSjoerg{
232*c303c47eSjoergpublic:
233*c303c47eSjoerg    class _LIBCPP_EXCEPTION_ABI failure;
234*c303c47eSjoerg
235*c303c47eSjoerg    typedef unsigned int fmtflags;
236*c303c47eSjoerg    static const fmtflags boolalpha   = 0x0001;
237*c303c47eSjoerg    static const fmtflags dec         = 0x0002;
238*c303c47eSjoerg    static const fmtflags fixed       = 0x0004;
239*c303c47eSjoerg    static const fmtflags hex         = 0x0008;
240*c303c47eSjoerg    static const fmtflags internal    = 0x0010;
241*c303c47eSjoerg    static const fmtflags left        = 0x0020;
242*c303c47eSjoerg    static const fmtflags oct         = 0x0040;
243*c303c47eSjoerg    static const fmtflags right       = 0x0080;
244*c303c47eSjoerg    static const fmtflags scientific  = 0x0100;
245*c303c47eSjoerg    static const fmtflags showbase    = 0x0200;
246*c303c47eSjoerg    static const fmtflags showpoint   = 0x0400;
247*c303c47eSjoerg    static const fmtflags showpos     = 0x0800;
248*c303c47eSjoerg    static const fmtflags skipws      = 0x1000;
249*c303c47eSjoerg    static const fmtflags unitbuf     = 0x2000;
250*c303c47eSjoerg    static const fmtflags uppercase   = 0x4000;
251*c303c47eSjoerg    static const fmtflags adjustfield = left | right | internal;
252*c303c47eSjoerg    static const fmtflags basefield   = dec | oct | hex;
253*c303c47eSjoerg    static const fmtflags floatfield  = scientific | fixed;
254*c303c47eSjoerg
255*c303c47eSjoerg    typedef unsigned int iostate;
256*c303c47eSjoerg    static const iostate badbit  = 0x1;
257*c303c47eSjoerg    static const iostate eofbit  = 0x2;
258*c303c47eSjoerg    static const iostate failbit = 0x4;
259*c303c47eSjoerg    static const iostate goodbit = 0x0;
260*c303c47eSjoerg
261*c303c47eSjoerg    typedef unsigned int openmode;
262*c303c47eSjoerg    static const openmode app    = 0x01;
263*c303c47eSjoerg    static const openmode ate    = 0x02;
264*c303c47eSjoerg    static const openmode binary = 0x04;
265*c303c47eSjoerg    static const openmode in     = 0x08;
266*c303c47eSjoerg    static const openmode out    = 0x10;
267*c303c47eSjoerg    static const openmode trunc  = 0x20;
268*c303c47eSjoerg
269*c303c47eSjoerg    enum seekdir {beg, cur, end};
270*c303c47eSjoerg
271*c303c47eSjoerg#if _LIBCPP_STD_VER <= 14
272*c303c47eSjoerg    typedef iostate      io_state;
273*c303c47eSjoerg    typedef openmode     open_mode;
274*c303c47eSjoerg    typedef seekdir      seek_dir;
275*c303c47eSjoerg
276*c303c47eSjoerg    typedef _VSTD::streamoff streamoff;
277*c303c47eSjoerg    typedef _VSTD::streampos streampos;
278*c303c47eSjoerg#endif
279*c303c47eSjoerg
280*c303c47eSjoerg    class _LIBCPP_TYPE_VIS Init;
281*c303c47eSjoerg
282*c303c47eSjoerg    // 27.5.2.2 fmtflags state:
283*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
284*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
285*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
286*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
287*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
288*c303c47eSjoerg
289*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY streamsize precision() const;
290*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
291*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY streamsize width() const;
292*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
293*c303c47eSjoerg
294*c303c47eSjoerg    // 27.5.2.3 locales:
295*c303c47eSjoerg    locale imbue(const locale& __loc);
296*c303c47eSjoerg    locale getloc() const;
297*c303c47eSjoerg
298*c303c47eSjoerg    // 27.5.2.5 storage:
299*c303c47eSjoerg    static int xalloc();
300*c303c47eSjoerg    long& iword(int __index);
301*c303c47eSjoerg    void*& pword(int __index);
302*c303c47eSjoerg
303*c303c47eSjoerg    // destructor
304*c303c47eSjoerg    virtual ~ios_base();
305*c303c47eSjoerg
306*c303c47eSjoerg    // 27.5.2.6 callbacks;
307*c303c47eSjoerg    enum event { erase_event, imbue_event, copyfmt_event };
308*c303c47eSjoerg    typedef void (*event_callback)(event, ios_base&, int __index);
309*c303c47eSjoerg    void register_callback(event_callback __fn, int __index);
310*c303c47eSjoerg
311*c303c47eSjoergprivate:
312*c303c47eSjoerg    ios_base(const ios_base&); // = delete;
313*c303c47eSjoerg    ios_base& operator=(const ios_base&); // = delete;
314*c303c47eSjoerg
315*c303c47eSjoergpublic:
316*c303c47eSjoerg    static bool sync_with_stdio(bool __sync = true);
317*c303c47eSjoerg
318*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
319*c303c47eSjoerg    void clear(iostate __state = goodbit);
320*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
321*c303c47eSjoerg
322*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool good() const;
323*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool eof() const;
324*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool fail() const;
325*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool bad() const;
326*c303c47eSjoerg
327*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
328*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate);
329*c303c47eSjoerg
330*c303c47eSjoerg    void __set_badbit_and_consider_rethrow();
331*c303c47eSjoerg    void __set_failbit_and_consider_rethrow();
332*c303c47eSjoerg
333*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
334*c303c47eSjoerg    void __setstate_nothrow(iostate __state)
335*c303c47eSjoerg    {
336*c303c47eSjoerg        if (__rdbuf_)
337*c303c47eSjoerg            __rdstate_ |= __state;
338*c303c47eSjoerg        else
339*c303c47eSjoerg            __rdstate_ |= __state | ios_base::badbit;
340*c303c47eSjoerg    }
341*c303c47eSjoerg
342*c303c47eSjoergprotected:
343*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
344*c303c47eSjoerg    ios_base() {// purposefully does no initialization
345*c303c47eSjoerg               }
346*c303c47eSjoerg
347*c303c47eSjoerg    void init(void* __sb);
348*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;}
349*c303c47eSjoerg
350*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
351*c303c47eSjoerg    void rdbuf(void* __sb)
352*c303c47eSjoerg    {
353*c303c47eSjoerg        __rdbuf_ = __sb;
354*c303c47eSjoerg        clear();
355*c303c47eSjoerg    }
356*c303c47eSjoerg
357*c303c47eSjoerg    void __call_callbacks(event);
358*c303c47eSjoerg    void copyfmt(const ios_base&);
359*c303c47eSjoerg    void move(ios_base&);
360*c303c47eSjoerg    void swap(ios_base&) _NOEXCEPT;
361*c303c47eSjoerg
362*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
363*c303c47eSjoerg    void set_rdbuf(void* __sb)
364*c303c47eSjoerg    {
365*c303c47eSjoerg        __rdbuf_ = __sb;
366*c303c47eSjoerg    }
367*c303c47eSjoerg
368*c303c47eSjoergprivate:
369*c303c47eSjoerg    // All data members must be scalars
370*c303c47eSjoerg    fmtflags        __fmtflags_;
371*c303c47eSjoerg    streamsize      __precision_;
372*c303c47eSjoerg    streamsize      __width_;
373*c303c47eSjoerg    iostate         __rdstate_;
374*c303c47eSjoerg    iostate         __exceptions_;
375*c303c47eSjoerg    void*           __rdbuf_;
376*c303c47eSjoerg    void*           __loc_;
377*c303c47eSjoerg    event_callback* __fn_;
378*c303c47eSjoerg    int*            __index_;
379*c303c47eSjoerg    size_t          __event_size_;
380*c303c47eSjoerg    size_t          __event_cap_;
381*c303c47eSjoerg// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
382*c303c47eSjoerg// enabled with clang.
383*c303c47eSjoerg#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
384*c303c47eSjoerg    static atomic<int> __xindex_;
385*c303c47eSjoerg#else
386*c303c47eSjoerg    static int      __xindex_;
387*c303c47eSjoerg#endif
388*c303c47eSjoerg    long*           __iarray_;
389*c303c47eSjoerg    size_t          __iarray_size_;
390*c303c47eSjoerg    size_t          __iarray_cap_;
391*c303c47eSjoerg    void**          __parray_;
392*c303c47eSjoerg    size_t          __parray_size_;
393*c303c47eSjoerg    size_t          __parray_cap_;
394*c303c47eSjoerg};
395*c303c47eSjoerg
396*c303c47eSjoerg//enum class io_errc
397*c303c47eSjoerg_LIBCPP_DECLARE_STRONG_ENUM(io_errc)
398*c303c47eSjoerg{
399*c303c47eSjoerg    stream = 1
400*c303c47eSjoerg};
401*c303c47eSjoerg_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
402*c303c47eSjoerg
403*c303c47eSjoergtemplate <>
404*c303c47eSjoergstruct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
405*c303c47eSjoerg
406*c303c47eSjoerg#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
407*c303c47eSjoergtemplate <>
408*c303c47eSjoergstruct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
409*c303c47eSjoerg#endif
410*c303c47eSjoerg
411*c303c47eSjoerg_LIBCPP_FUNC_VIS
412*c303c47eSjoergconst error_category& iostream_category() _NOEXCEPT;
413*c303c47eSjoerg
414*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
415*c303c47eSjoergerror_code
416*c303c47eSjoergmake_error_code(io_errc __e) _NOEXCEPT
417*c303c47eSjoerg{
418*c303c47eSjoerg    return error_code(static_cast<int>(__e), iostream_category());
419*c303c47eSjoerg}
420*c303c47eSjoerg
421*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
422*c303c47eSjoergerror_condition
423*c303c47eSjoergmake_error_condition(io_errc __e) _NOEXCEPT
424*c303c47eSjoerg{
425*c303c47eSjoerg    return error_condition(static_cast<int>(__e), iostream_category());
426*c303c47eSjoerg}
427*c303c47eSjoerg
428*c303c47eSjoergclass _LIBCPP_EXCEPTION_ABI ios_base::failure
429*c303c47eSjoerg    : public system_error
430*c303c47eSjoerg{
431*c303c47eSjoergpublic:
432*c303c47eSjoerg    explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
433*c303c47eSjoerg    explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
434*c303c47eSjoerg    failure(const failure&) _NOEXCEPT = default;
435*c303c47eSjoerg    virtual ~failure() _NOEXCEPT;
436*c303c47eSjoerg};
437*c303c47eSjoerg
438*c303c47eSjoerg_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
439*c303c47eSjoergvoid __throw_failure(char const* __msg) {
440*c303c47eSjoerg#ifndef _LIBCPP_NO_EXCEPTIONS
441*c303c47eSjoerg    throw ios_base::failure(__msg);
442*c303c47eSjoerg#else
443*c303c47eSjoerg    ((void)__msg);
444*c303c47eSjoerg    _VSTD::abort();
445*c303c47eSjoerg#endif
446*c303c47eSjoerg}
447*c303c47eSjoerg
448*c303c47eSjoergclass _LIBCPP_TYPE_VIS ios_base::Init
449*c303c47eSjoerg{
450*c303c47eSjoergpublic:
451*c303c47eSjoerg    Init();
452*c303c47eSjoerg    ~Init();
453*c303c47eSjoerg};
454*c303c47eSjoerg
455*c303c47eSjoerg// fmtflags
456*c303c47eSjoerg
457*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
458*c303c47eSjoergios_base::fmtflags
459*c303c47eSjoergios_base::flags() const
460*c303c47eSjoerg{
461*c303c47eSjoerg    return __fmtflags_;
462*c303c47eSjoerg}
463*c303c47eSjoerg
464*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
465*c303c47eSjoergios_base::fmtflags
466*c303c47eSjoergios_base::flags(fmtflags __fmtfl)
467*c303c47eSjoerg{
468*c303c47eSjoerg    fmtflags __r = __fmtflags_;
469*c303c47eSjoerg    __fmtflags_ = __fmtfl;
470*c303c47eSjoerg    return __r;
471*c303c47eSjoerg}
472*c303c47eSjoerg
473*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
474*c303c47eSjoergios_base::fmtflags
475*c303c47eSjoergios_base::setf(fmtflags __fmtfl)
476*c303c47eSjoerg{
477*c303c47eSjoerg    fmtflags __r = __fmtflags_;
478*c303c47eSjoerg    __fmtflags_ |= __fmtfl;
479*c303c47eSjoerg    return __r;
480*c303c47eSjoerg}
481*c303c47eSjoerg
482*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
483*c303c47eSjoergvoid
484*c303c47eSjoergios_base::unsetf(fmtflags __mask)
485*c303c47eSjoerg{
486*c303c47eSjoerg    __fmtflags_ &= ~__mask;
487*c303c47eSjoerg}
488*c303c47eSjoerg
489*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
490*c303c47eSjoergios_base::fmtflags
491*c303c47eSjoergios_base::setf(fmtflags __fmtfl, fmtflags __mask)
492*c303c47eSjoerg{
493*c303c47eSjoerg    fmtflags __r = __fmtflags_;
494*c303c47eSjoerg    unsetf(__mask);
495*c303c47eSjoerg    __fmtflags_ |= __fmtfl & __mask;
496*c303c47eSjoerg    return __r;
497*c303c47eSjoerg}
498*c303c47eSjoerg
499*c303c47eSjoerg// precision
500*c303c47eSjoerg
501*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
502*c303c47eSjoergstreamsize
503*c303c47eSjoergios_base::precision() const
504*c303c47eSjoerg{
505*c303c47eSjoerg    return __precision_;
506*c303c47eSjoerg}
507*c303c47eSjoerg
508*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
509*c303c47eSjoergstreamsize
510*c303c47eSjoergios_base::precision(streamsize __prec)
511*c303c47eSjoerg{
512*c303c47eSjoerg    streamsize __r = __precision_;
513*c303c47eSjoerg    __precision_ = __prec;
514*c303c47eSjoerg    return __r;
515*c303c47eSjoerg}
516*c303c47eSjoerg
517*c303c47eSjoerg// width
518*c303c47eSjoerg
519*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
520*c303c47eSjoergstreamsize
521*c303c47eSjoergios_base::width() const
522*c303c47eSjoerg{
523*c303c47eSjoerg    return __width_;
524*c303c47eSjoerg}
525*c303c47eSjoerg
526*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
527*c303c47eSjoergstreamsize
528*c303c47eSjoergios_base::width(streamsize __wide)
529*c303c47eSjoerg{
530*c303c47eSjoerg    streamsize __r = __width_;
531*c303c47eSjoerg    __width_ = __wide;
532*c303c47eSjoerg    return __r;
533*c303c47eSjoerg}
534*c303c47eSjoerg
535*c303c47eSjoerg// iostate
536*c303c47eSjoerg
537*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
538*c303c47eSjoergios_base::iostate
539*c303c47eSjoergios_base::rdstate() const
540*c303c47eSjoerg{
541*c303c47eSjoerg    return __rdstate_;
542*c303c47eSjoerg}
543*c303c47eSjoerg
544*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
545*c303c47eSjoergvoid
546*c303c47eSjoergios_base::setstate(iostate __state)
547*c303c47eSjoerg{
548*c303c47eSjoerg    clear(__rdstate_ | __state);
549*c303c47eSjoerg}
550*c303c47eSjoerg
551*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
552*c303c47eSjoergbool
553*c303c47eSjoergios_base::good() const
554*c303c47eSjoerg{
555*c303c47eSjoerg    return __rdstate_ == 0;
556*c303c47eSjoerg}
557*c303c47eSjoerg
558*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
559*c303c47eSjoergbool
560*c303c47eSjoergios_base::eof() const
561*c303c47eSjoerg{
562*c303c47eSjoerg    return (__rdstate_ & eofbit) != 0;
563*c303c47eSjoerg}
564*c303c47eSjoerg
565*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
566*c303c47eSjoergbool
567*c303c47eSjoergios_base::fail() const
568*c303c47eSjoerg{
569*c303c47eSjoerg    return (__rdstate_ & (failbit | badbit)) != 0;
570*c303c47eSjoerg}
571*c303c47eSjoerg
572*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
573*c303c47eSjoergbool
574*c303c47eSjoergios_base::bad() const
575*c303c47eSjoerg{
576*c303c47eSjoerg    return (__rdstate_ & badbit) != 0;
577*c303c47eSjoerg}
578*c303c47eSjoerg
579*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
580*c303c47eSjoergios_base::iostate
581*c303c47eSjoergios_base::exceptions() const
582*c303c47eSjoerg{
583*c303c47eSjoerg    return __exceptions_;
584*c303c47eSjoerg}
585*c303c47eSjoerg
586*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
587*c303c47eSjoergvoid
588*c303c47eSjoergios_base::exceptions(iostate __iostate)
589*c303c47eSjoerg{
590*c303c47eSjoerg    __exceptions_ = __iostate;
591*c303c47eSjoerg    clear(__rdstate_);
592*c303c47eSjoerg}
593*c303c47eSjoerg
594*c303c47eSjoerg#if defined(_LIBCPP_CXX03_LANG)
595*c303c47eSjoergstruct _LIBCPP_TYPE_VIS __cxx03_bool {
596*c303c47eSjoerg  typedef void (__cxx03_bool::*__bool_type)();
597*c303c47eSjoerg  void __true_value() {}
598*c303c47eSjoerg};
599*c303c47eSjoerg#endif
600*c303c47eSjoerg
601*c303c47eSjoergtemplate <class _CharT, class _Traits>
602*c303c47eSjoergclass _LIBCPP_TEMPLATE_VIS basic_ios
603*c303c47eSjoerg    : public ios_base
604*c303c47eSjoerg{
605*c303c47eSjoergpublic:
606*c303c47eSjoerg    // types:
607*c303c47eSjoerg    typedef _CharT char_type;
608*c303c47eSjoerg    typedef _Traits traits_type;
609*c303c47eSjoerg
610*c303c47eSjoerg    typedef typename traits_type::int_type int_type;
611*c303c47eSjoerg    typedef typename traits_type::pos_type pos_type;
612*c303c47eSjoerg    typedef typename traits_type::off_type off_type;
613*c303c47eSjoerg
614*c303c47eSjoerg    static_assert((is_same<_CharT, typename traits_type::char_type>::value),
615*c303c47eSjoerg                  "traits_type::char_type must be the same type as CharT");
616*c303c47eSjoerg
617*c303c47eSjoerg  // __true_value will generate undefined references when linking unless
618*c303c47eSjoerg  // we give it internal linkage.
619*c303c47eSjoerg
620*c303c47eSjoerg#if defined(_LIBCPP_CXX03_LANG)
621*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
622*c303c47eSjoerg    operator __cxx03_bool::__bool_type() const {
623*c303c47eSjoerg        return !fail() ? &__cxx03_bool::__true_value : nullptr;
624*c303c47eSjoerg    }
625*c303c47eSjoerg#else
626*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
627*c303c47eSjoerg    _LIBCPP_EXPLICIT operator bool() const {return !fail();}
628*c303c47eSjoerg#endif
629*c303c47eSjoerg
630*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool operator!() const    {return  fail();}
631*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY iostate rdstate() const   {return ios_base::rdstate();}
632*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);}
633*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);}
634*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();}
635*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool eof() const  {return ios_base::eof();}
636*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();}
637*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY bool bad() const  {return ios_base::bad();}
638*c303c47eSjoerg
639*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();}
640*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
641*c303c47eSjoerg
642*c303c47eSjoerg    // 27.5.4.1 Constructor/destructor:
643*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
644*c303c47eSjoerg    explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
645*c303c47eSjoerg    virtual ~basic_ios();
646*c303c47eSjoerg
647*c303c47eSjoerg    // 27.5.4.2 Members:
648*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
649*c303c47eSjoerg    basic_ostream<char_type, traits_type>* tie() const;
650*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
651*c303c47eSjoerg    basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
652*c303c47eSjoerg
653*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
654*c303c47eSjoerg    basic_streambuf<char_type, traits_type>* rdbuf() const;
655*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
656*c303c47eSjoerg    basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
657*c303c47eSjoerg
658*c303c47eSjoerg    basic_ios& copyfmt(const basic_ios& __rhs);
659*c303c47eSjoerg
660*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
661*c303c47eSjoerg    char_type fill() const;
662*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
663*c303c47eSjoerg    char_type fill(char_type __ch);
664*c303c47eSjoerg
665*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
666*c303c47eSjoerg    locale imbue(const locale& __loc);
667*c303c47eSjoerg
668*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
669*c303c47eSjoerg    char narrow(char_type __c, char __dfault) const;
670*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
671*c303c47eSjoerg    char_type widen(char __c) const;
672*c303c47eSjoerg
673*c303c47eSjoergprotected:
674*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
675*c303c47eSjoerg    basic_ios() {// purposefully does no initialization
676*c303c47eSjoerg                }
677*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
678*c303c47eSjoerg    void init(basic_streambuf<char_type, traits_type>* __sb);
679*c303c47eSjoerg
680*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
681*c303c47eSjoerg    void move(basic_ios& __rhs);
682*c303c47eSjoerg#ifndef _LIBCPP_CXX03_LANG
683*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
684*c303c47eSjoerg    void move(basic_ios&& __rhs) {move(__rhs);}
685*c303c47eSjoerg#endif
686*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
687*c303c47eSjoerg    void swap(basic_ios& __rhs) _NOEXCEPT;
688*c303c47eSjoerg    _LIBCPP_INLINE_VISIBILITY
689*c303c47eSjoerg    void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
690*c303c47eSjoergprivate:
691*c303c47eSjoerg    basic_ostream<char_type, traits_type>* __tie_;
692*c303c47eSjoerg    mutable int_type __fill_;
693*c303c47eSjoerg};
694*c303c47eSjoerg
695*c303c47eSjoergtemplate <class _CharT, class _Traits>
696*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
697*c303c47eSjoergbasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
698*c303c47eSjoerg{
699*c303c47eSjoerg    init(__sb);
700*c303c47eSjoerg}
701*c303c47eSjoerg
702*c303c47eSjoergtemplate <class _CharT, class _Traits>
703*c303c47eSjoergbasic_ios<_CharT, _Traits>::~basic_ios()
704*c303c47eSjoerg{
705*c303c47eSjoerg}
706*c303c47eSjoerg
707*c303c47eSjoergtemplate <class _CharT, class _Traits>
708*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
709*c303c47eSjoergvoid
710*c303c47eSjoergbasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
711*c303c47eSjoerg{
712*c303c47eSjoerg    ios_base::init(__sb);
713*c303c47eSjoerg    __tie_ = nullptr;
714*c303c47eSjoerg    __fill_ = traits_type::eof();
715*c303c47eSjoerg}
716*c303c47eSjoerg
717*c303c47eSjoergtemplate <class _CharT, class _Traits>
718*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
719*c303c47eSjoergbasic_ostream<_CharT, _Traits>*
720*c303c47eSjoergbasic_ios<_CharT, _Traits>::tie() const
721*c303c47eSjoerg{
722*c303c47eSjoerg    return __tie_;
723*c303c47eSjoerg}
724*c303c47eSjoerg
725*c303c47eSjoergtemplate <class _CharT, class _Traits>
726*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
727*c303c47eSjoergbasic_ostream<_CharT, _Traits>*
728*c303c47eSjoergbasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
729*c303c47eSjoerg{
730*c303c47eSjoerg    basic_ostream<char_type, traits_type>* __r = __tie_;
731*c303c47eSjoerg    __tie_ = __tiestr;
732*c303c47eSjoerg    return __r;
733*c303c47eSjoerg}
734*c303c47eSjoerg
735*c303c47eSjoergtemplate <class _CharT, class _Traits>
736*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
737*c303c47eSjoergbasic_streambuf<_CharT, _Traits>*
738*c303c47eSjoergbasic_ios<_CharT, _Traits>::rdbuf() const
739*c303c47eSjoerg{
740*c303c47eSjoerg    return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
741*c303c47eSjoerg}
742*c303c47eSjoerg
743*c303c47eSjoergtemplate <class _CharT, class _Traits>
744*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
745*c303c47eSjoergbasic_streambuf<_CharT, _Traits>*
746*c303c47eSjoergbasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
747*c303c47eSjoerg{
748*c303c47eSjoerg    basic_streambuf<char_type, traits_type>* __r = rdbuf();
749*c303c47eSjoerg    ios_base::rdbuf(__sb);
750*c303c47eSjoerg    return __r;
751*c303c47eSjoerg}
752*c303c47eSjoerg
753*c303c47eSjoergtemplate <class _CharT, class _Traits>
754*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
755*c303c47eSjoerglocale
756*c303c47eSjoergbasic_ios<_CharT, _Traits>::imbue(const locale& __loc)
757*c303c47eSjoerg{
758*c303c47eSjoerg    locale __r = getloc();
759*c303c47eSjoerg    ios_base::imbue(__loc);
760*c303c47eSjoerg    if (rdbuf())
761*c303c47eSjoerg        rdbuf()->pubimbue(__loc);
762*c303c47eSjoerg    return __r;
763*c303c47eSjoerg}
764*c303c47eSjoerg
765*c303c47eSjoergtemplate <class _CharT, class _Traits>
766*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
767*c303c47eSjoergchar
768*c303c47eSjoergbasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
769*c303c47eSjoerg{
770*c303c47eSjoerg    return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
771*c303c47eSjoerg}
772*c303c47eSjoerg
773*c303c47eSjoergtemplate <class _CharT, class _Traits>
774*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
775*c303c47eSjoerg_CharT
776*c303c47eSjoergbasic_ios<_CharT, _Traits>::widen(char __c) const
777*c303c47eSjoerg{
778*c303c47eSjoerg    return use_facet<ctype<char_type> >(getloc()).widen(__c);
779*c303c47eSjoerg}
780*c303c47eSjoerg
781*c303c47eSjoergtemplate <class _CharT, class _Traits>
782*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
783*c303c47eSjoerg_CharT
784*c303c47eSjoergbasic_ios<_CharT, _Traits>::fill() const
785*c303c47eSjoerg{
786*c303c47eSjoerg    if (traits_type::eq_int_type(traits_type::eof(), __fill_))
787*c303c47eSjoerg        __fill_ = widen(' ');
788*c303c47eSjoerg    return __fill_;
789*c303c47eSjoerg}
790*c303c47eSjoerg
791*c303c47eSjoergtemplate <class _CharT, class _Traits>
792*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
793*c303c47eSjoerg_CharT
794*c303c47eSjoergbasic_ios<_CharT, _Traits>::fill(char_type __ch)
795*c303c47eSjoerg{
796*c303c47eSjoerg    char_type __r = __fill_;
797*c303c47eSjoerg    __fill_ = __ch;
798*c303c47eSjoerg    return __r;
799*c303c47eSjoerg}
800*c303c47eSjoerg
801*c303c47eSjoergtemplate <class _CharT, class _Traits>
802*c303c47eSjoergbasic_ios<_CharT, _Traits>&
803*c303c47eSjoergbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
804*c303c47eSjoerg{
805*c303c47eSjoerg    if (this != &__rhs)
806*c303c47eSjoerg    {
807*c303c47eSjoerg        __call_callbacks(erase_event);
808*c303c47eSjoerg        ios_base::copyfmt(__rhs);
809*c303c47eSjoerg        __tie_ = __rhs.__tie_;
810*c303c47eSjoerg        __fill_ = __rhs.__fill_;
811*c303c47eSjoerg        __call_callbacks(copyfmt_event);
812*c303c47eSjoerg        exceptions(__rhs.exceptions());
813*c303c47eSjoerg    }
814*c303c47eSjoerg    return *this;
815*c303c47eSjoerg}
816*c303c47eSjoerg
817*c303c47eSjoergtemplate <class _CharT, class _Traits>
818*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
819*c303c47eSjoergvoid
820*c303c47eSjoergbasic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
821*c303c47eSjoerg{
822*c303c47eSjoerg    ios_base::move(__rhs);
823*c303c47eSjoerg    __tie_ = __rhs.__tie_;
824*c303c47eSjoerg    __rhs.__tie_ = nullptr;
825*c303c47eSjoerg    __fill_ = __rhs.__fill_;
826*c303c47eSjoerg}
827*c303c47eSjoerg
828*c303c47eSjoergtemplate <class _CharT, class _Traits>
829*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
830*c303c47eSjoergvoid
831*c303c47eSjoergbasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT
832*c303c47eSjoerg{
833*c303c47eSjoerg    ios_base::swap(__rhs);
834*c303c47eSjoerg    _VSTD::swap(__tie_, __rhs.__tie_);
835*c303c47eSjoerg    _VSTD::swap(__fill_, __rhs.__fill_);
836*c303c47eSjoerg}
837*c303c47eSjoerg
838*c303c47eSjoergtemplate <class _CharT, class _Traits>
839*c303c47eSjoerginline _LIBCPP_INLINE_VISIBILITY
840*c303c47eSjoergvoid
841*c303c47eSjoergbasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
842*c303c47eSjoerg{
843*c303c47eSjoerg    ios_base::set_rdbuf(__sb);
844*c303c47eSjoerg}
845*c303c47eSjoerg
846*c303c47eSjoerginline
847*c303c47eSjoergios_base&
848*c303c47eSjoergboolalpha(ios_base& __str)
849*c303c47eSjoerg{
850*c303c47eSjoerg    __str.setf(ios_base::boolalpha);
851*c303c47eSjoerg    return __str;
852*c303c47eSjoerg}
853*c303c47eSjoerg
854*c303c47eSjoerginline
855*c303c47eSjoergios_base&
856*c303c47eSjoergnoboolalpha(ios_base& __str)
857*c303c47eSjoerg{
858*c303c47eSjoerg    __str.unsetf(ios_base::boolalpha);
859*c303c47eSjoerg    return __str;
860*c303c47eSjoerg}
861*c303c47eSjoerg
862*c303c47eSjoerginline
863*c303c47eSjoergios_base&
864*c303c47eSjoergshowbase(ios_base& __str)
865*c303c47eSjoerg{
866*c303c47eSjoerg    __str.setf(ios_base::showbase);
867*c303c47eSjoerg    return __str;
868*c303c47eSjoerg}
869*c303c47eSjoerg
870*c303c47eSjoerginline
871*c303c47eSjoergios_base&
872*c303c47eSjoergnoshowbase(ios_base& __str)
873*c303c47eSjoerg{
874*c303c47eSjoerg    __str.unsetf(ios_base::showbase);
875*c303c47eSjoerg    return __str;
876*c303c47eSjoerg}
877*c303c47eSjoerg
878*c303c47eSjoerginline
879*c303c47eSjoergios_base&
880*c303c47eSjoergshowpoint(ios_base& __str)
881*c303c47eSjoerg{
882*c303c47eSjoerg    __str.setf(ios_base::showpoint);
883*c303c47eSjoerg    return __str;
884*c303c47eSjoerg}
885*c303c47eSjoerg
886*c303c47eSjoerginline
887*c303c47eSjoergios_base&
888*c303c47eSjoergnoshowpoint(ios_base& __str)
889*c303c47eSjoerg{
890*c303c47eSjoerg    __str.unsetf(ios_base::showpoint);
891*c303c47eSjoerg    return __str;
892*c303c47eSjoerg}
893*c303c47eSjoerg
894*c303c47eSjoerginline
895*c303c47eSjoergios_base&
896*c303c47eSjoergshowpos(ios_base& __str)
897*c303c47eSjoerg{
898*c303c47eSjoerg    __str.setf(ios_base::showpos);
899*c303c47eSjoerg    return __str;
900*c303c47eSjoerg}
901*c303c47eSjoerg
902*c303c47eSjoerginline
903*c303c47eSjoergios_base&
904*c303c47eSjoergnoshowpos(ios_base& __str)
905*c303c47eSjoerg{
906*c303c47eSjoerg    __str.unsetf(ios_base::showpos);
907*c303c47eSjoerg    return __str;
908*c303c47eSjoerg}
909*c303c47eSjoerg
910*c303c47eSjoerginline
911*c303c47eSjoergios_base&
912*c303c47eSjoergskipws(ios_base& __str)
913*c303c47eSjoerg{
914*c303c47eSjoerg    __str.setf(ios_base::skipws);
915*c303c47eSjoerg    return __str;
916*c303c47eSjoerg}
917*c303c47eSjoerg
918*c303c47eSjoerginline
919*c303c47eSjoergios_base&
920*c303c47eSjoergnoskipws(ios_base& __str)
921*c303c47eSjoerg{
922*c303c47eSjoerg    __str.unsetf(ios_base::skipws);
923*c303c47eSjoerg    return __str;
924*c303c47eSjoerg}
925*c303c47eSjoerg
926*c303c47eSjoerginline
927*c303c47eSjoergios_base&
928*c303c47eSjoerguppercase(ios_base& __str)
929*c303c47eSjoerg{
930*c303c47eSjoerg    __str.setf(ios_base::uppercase);
931*c303c47eSjoerg    return __str;
932*c303c47eSjoerg}
933*c303c47eSjoerg
934*c303c47eSjoerginline
935*c303c47eSjoergios_base&
936*c303c47eSjoergnouppercase(ios_base& __str)
937*c303c47eSjoerg{
938*c303c47eSjoerg    __str.unsetf(ios_base::uppercase);
939*c303c47eSjoerg    return __str;
940*c303c47eSjoerg}
941*c303c47eSjoerg
942*c303c47eSjoerginline
943*c303c47eSjoergios_base&
944*c303c47eSjoergunitbuf(ios_base& __str)
945*c303c47eSjoerg{
946*c303c47eSjoerg    __str.setf(ios_base::unitbuf);
947*c303c47eSjoerg    return __str;
948*c303c47eSjoerg}
949*c303c47eSjoerg
950*c303c47eSjoerginline
951*c303c47eSjoergios_base&
952*c303c47eSjoergnounitbuf(ios_base& __str)
953*c303c47eSjoerg{
954*c303c47eSjoerg    __str.unsetf(ios_base::unitbuf);
955*c303c47eSjoerg    return __str;
956*c303c47eSjoerg}
957*c303c47eSjoerg
958*c303c47eSjoerginline
959*c303c47eSjoergios_base&
960*c303c47eSjoerginternal(ios_base& __str)
961*c303c47eSjoerg{
962*c303c47eSjoerg    __str.setf(ios_base::internal, ios_base::adjustfield);
963*c303c47eSjoerg    return __str;
964*c303c47eSjoerg}
965*c303c47eSjoerg
966*c303c47eSjoerginline
967*c303c47eSjoergios_base&
968*c303c47eSjoergleft(ios_base& __str)
969*c303c47eSjoerg{
970*c303c47eSjoerg    __str.setf(ios_base::left, ios_base::adjustfield);
971*c303c47eSjoerg    return __str;
972*c303c47eSjoerg}
973*c303c47eSjoerg
974*c303c47eSjoerginline
975*c303c47eSjoergios_base&
976*c303c47eSjoergright(ios_base& __str)
977*c303c47eSjoerg{
978*c303c47eSjoerg    __str.setf(ios_base::right, ios_base::adjustfield);
979*c303c47eSjoerg    return __str;
980*c303c47eSjoerg}
981*c303c47eSjoerg
982*c303c47eSjoerginline
983*c303c47eSjoergios_base&
984*c303c47eSjoergdec(ios_base& __str)
985*c303c47eSjoerg{
986*c303c47eSjoerg    __str.setf(ios_base::dec, ios_base::basefield);
987*c303c47eSjoerg    return __str;
988*c303c47eSjoerg}
989*c303c47eSjoerg
990*c303c47eSjoerginline
991*c303c47eSjoergios_base&
992*c303c47eSjoerghex(ios_base& __str)
993*c303c47eSjoerg{
994*c303c47eSjoerg    __str.setf(ios_base::hex, ios_base::basefield);
995*c303c47eSjoerg    return __str;
996*c303c47eSjoerg}
997*c303c47eSjoerg
998*c303c47eSjoerginline
999*c303c47eSjoergios_base&
1000*c303c47eSjoergoct(ios_base& __str)
1001*c303c47eSjoerg{
1002*c303c47eSjoerg    __str.setf(ios_base::oct, ios_base::basefield);
1003*c303c47eSjoerg    return __str;
1004*c303c47eSjoerg}
1005*c303c47eSjoerg
1006*c303c47eSjoerginline
1007*c303c47eSjoergios_base&
1008*c303c47eSjoergfixed(ios_base& __str)
1009*c303c47eSjoerg{
1010*c303c47eSjoerg    __str.setf(ios_base::fixed, ios_base::floatfield);
1011*c303c47eSjoerg    return __str;
1012*c303c47eSjoerg}
1013*c303c47eSjoerg
1014*c303c47eSjoerginline
1015*c303c47eSjoergios_base&
1016*c303c47eSjoergscientific(ios_base& __str)
1017*c303c47eSjoerg{
1018*c303c47eSjoerg    __str.setf(ios_base::scientific, ios_base::floatfield);
1019*c303c47eSjoerg    return __str;
1020*c303c47eSjoerg}
1021*c303c47eSjoerg
1022*c303c47eSjoerginline
1023*c303c47eSjoergios_base&
1024*c303c47eSjoerghexfloat(ios_base& __str)
1025*c303c47eSjoerg{
1026*c303c47eSjoerg    __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
1027*c303c47eSjoerg    return __str;
1028*c303c47eSjoerg}
1029*c303c47eSjoerg
1030*c303c47eSjoerginline
1031*c303c47eSjoergios_base&
1032*c303c47eSjoergdefaultfloat(ios_base& __str)
1033*c303c47eSjoerg{
1034*c303c47eSjoerg    __str.unsetf(ios_base::floatfield);
1035*c303c47eSjoerg    return __str;
1036*c303c47eSjoerg}
1037*c303c47eSjoerg
1038*c303c47eSjoerg_LIBCPP_END_NAMESPACE_STD
1039*c303c47eSjoerg
1040*c303c47eSjoerg#endif // _LIBCPP_IOS
1041