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