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