llvm-project
851 строка · 25.2 Кб
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
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/*
14ios 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:
28class failure;
29
30typedef T1 fmtflags;
31static constexpr fmtflags boolalpha;
32static constexpr fmtflags dec;
33static constexpr fmtflags fixed;
34static constexpr fmtflags hex;
35static constexpr fmtflags internal;
36static constexpr fmtflags left;
37static constexpr fmtflags oct;
38static constexpr fmtflags right;
39static constexpr fmtflags scientific;
40static constexpr fmtflags showbase;
41static constexpr fmtflags showpoint;
42static constexpr fmtflags showpos;
43static constexpr fmtflags skipws;
44static constexpr fmtflags unitbuf;
45static constexpr fmtflags uppercase;
46static constexpr fmtflags adjustfield;
47static constexpr fmtflags basefield;
48static constexpr fmtflags floatfield;
49
50typedef T2 iostate;
51static constexpr iostate badbit;
52static constexpr iostate eofbit;
53static constexpr iostate failbit;
54static constexpr iostate goodbit;
55
56typedef T3 openmode;
57static constexpr openmode app;
58static constexpr openmode ate;
59static constexpr openmode binary;
60static constexpr openmode in;
61static constexpr openmode noreplace; // since C++23
62static constexpr openmode out;
63static constexpr openmode trunc;
64
65typedef T4 seekdir;
66static constexpr seekdir beg;
67static constexpr seekdir cur;
68static constexpr seekdir end;
69
70class Init;
71
72// 27.5.2.2 fmtflags state:
73fmtflags flags() const;
74fmtflags flags(fmtflags fmtfl);
75fmtflags setf(fmtflags fmtfl);
76fmtflags setf(fmtflags fmtfl, fmtflags mask);
77void unsetf(fmtflags mask);
78
79streamsize precision() const;
80streamsize precision(streamsize prec);
81streamsize width() const;
82streamsize width(streamsize wide);
83
84// 27.5.2.3 locales:
85locale imbue(const locale& loc);
86locale getloc() const;
87
88// 27.5.2.5 storage:
89static int xalloc();
90long& iword(int index);
91void*& pword(int index);
92
93// destructor
94virtual ~ios_base();
95
96// 27.5.2.6 callbacks;
97enum event { erase_event, imbue_event, copyfmt_event };
98typedef void (*event_callback)(event, ios_base&, int index);
99void register_callback(event_callback fn, int index);
100
101ios_base(const ios_base&) = delete;
102ios_base& operator=(const ios_base&) = delete;
103
104static bool sync_with_stdio(bool sync = true);
105
106protected:
107ios_base();
108};
109
110template <class charT, class traits = char_traits<charT> >
111class basic_ios
112: public ios_base
113{
114public:
115// types:
116typedef charT char_type;
117typedef typename traits::int_type int_type; // removed in C++17
118typedef typename traits::pos_type pos_type; // removed in C++17
119typedef typename traits::off_type off_type; // removed in C++17
120typedef traits traits_type;
121
122operator unspecified-bool-type() const;
123bool operator!() const;
124iostate rdstate() const;
125void clear(iostate state = goodbit);
126void setstate(iostate state);
127bool good() const;
128bool eof() const;
129bool fail() const;
130bool bad() const;
131
132iostate exceptions() const;
133void exceptions(iostate except);
134
135// 27.5.4.1 Constructor/destructor:
136explicit basic_ios(basic_streambuf<charT,traits>* sb);
137virtual ~basic_ios();
138
139// 27.5.4.2 Members:
140basic_ostream<charT,traits>* tie() const;
141basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
142
143basic_streambuf<charT,traits>* rdbuf() const;
144basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
145
146basic_ios& copyfmt(const basic_ios& rhs);
147
148char_type fill() const;
149char_type fill(char_type ch);
150
151locale imbue(const locale& loc);
152
153char narrow(char_type c, char dfault) const;
154char_type widen(char c) const;
155
156basic_ios(const basic_ios& ) = delete;
157basic_ios& operator=(const basic_ios&) = delete;
158
159protected:
160basic_ios();
161void init(basic_streambuf<charT,traits>* sb);
162void move(basic_ios& rhs);
163void swap(basic_ios& rhs) noexcept;
164void 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{
202stream = 1
203};
204
205concept_map ErrorCodeEnum<io_errc> { };
206error_code make_error_code(io_errc e) noexcept;
207error_condition make_error_condition(io_errc e) noexcept;
208storage-class-specifier const error_category& iostream_category() noexcept;
209
210} // std
211
212*/
213
214#include <__config>
215
216#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
217# error "The iostreams library is not supported since libc++ has been configured without support for localization."
218#endif
219
220#include <__fwd/ios.h>
221#include <__ios/fpos.h>
222#include <__locale>
223#include <__system_error/error_category.h>
224#include <__system_error/error_code.h>
225#include <__system_error/error_condition.h>
226#include <__system_error/system_error.h>
227#include <__utility/swap.h>
228#include <__verbose_abort>
229#include <version>
230
231// standard-mandated includes
232
233// [ios.syn]
234#include <iosfwd>
235
236#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
237# include <__atomic/atomic.h> // for __xindex_
238#endif
239
240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
241# pragma GCC system_header
242#endif
243
244_LIBCPP_PUSH_MACROS
245#include <__undef_macros>
246
247_LIBCPP_BEGIN_NAMESPACE_STD
248
249typedef ptrdiff_t streamsize;
250
251class _LIBCPP_EXPORTED_FROM_ABI ios_base {
252public:
253class _LIBCPP_EXPORTED_FROM_ABI failure;
254
255typedef unsigned int fmtflags;
256static const fmtflags boolalpha = 0x0001;
257static const fmtflags dec = 0x0002;
258static const fmtflags fixed = 0x0004;
259static const fmtflags hex = 0x0008;
260static const fmtflags internal = 0x0010;
261static const fmtflags left = 0x0020;
262static const fmtflags oct = 0x0040;
263static const fmtflags right = 0x0080;
264static const fmtflags scientific = 0x0100;
265static const fmtflags showbase = 0x0200;
266static const fmtflags showpoint = 0x0400;
267static const fmtflags showpos = 0x0800;
268static const fmtflags skipws = 0x1000;
269static const fmtflags unitbuf = 0x2000;
270static const fmtflags uppercase = 0x4000;
271static const fmtflags adjustfield = left | right | internal;
272static const fmtflags basefield = dec | oct | hex;
273static const fmtflags floatfield = scientific | fixed;
274
275typedef unsigned int iostate;
276static const iostate badbit = 0x1;
277static const iostate eofbit = 0x2;
278static const iostate failbit = 0x4;
279static const iostate goodbit = 0x0;
280
281typedef unsigned int openmode;
282static const openmode app = 0x01;
283static const openmode ate = 0x02;
284static const openmode binary = 0x04;
285static const openmode in = 0x08;
286static const openmode out = 0x10;
287static const openmode trunc = 0x20;
288#if _LIBCPP_STD_VER >= 23
289static const openmode noreplace = 0x40;
290#endif
291
292enum seekdir { beg, cur, end };
293
294#if _LIBCPP_STD_VER <= 14
295typedef iostate io_state;
296typedef openmode open_mode;
297typedef seekdir seek_dir;
298
299typedef std::streamoff streamoff;
300typedef std::streampos streampos;
301#endif
302
303class _LIBCPP_EXPORTED_FROM_ABI Init;
304
305// 27.5.2.2 fmtflags state:
306_LIBCPP_HIDE_FROM_ABI fmtflags flags() const;
307_LIBCPP_HIDE_FROM_ABI fmtflags flags(fmtflags __fmtfl);
308_LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl);
309_LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
310_LIBCPP_HIDE_FROM_ABI void unsetf(fmtflags __mask);
311
312_LIBCPP_HIDE_FROM_ABI streamsize precision() const;
313_LIBCPP_HIDE_FROM_ABI streamsize precision(streamsize __prec);
314_LIBCPP_HIDE_FROM_ABI streamsize width() const;
315_LIBCPP_HIDE_FROM_ABI streamsize width(streamsize __wide);
316
317// 27.5.2.3 locales:
318locale imbue(const locale& __loc);
319locale getloc() const;
320
321// 27.5.2.5 storage:
322static int xalloc();
323long& iword(int __index);
324void*& pword(int __index);
325
326// destructor
327virtual ~ios_base();
328
329// 27.5.2.6 callbacks;
330enum event { erase_event, imbue_event, copyfmt_event };
331typedef void (*event_callback)(event, ios_base&, int __index);
332void register_callback(event_callback __fn, int __index);
333
334ios_base(const ios_base&) = delete;
335ios_base& operator=(const ios_base&) = delete;
336
337static bool sync_with_stdio(bool __sync = true);
338
339_LIBCPP_HIDE_FROM_ABI iostate rdstate() const;
340void clear(iostate __state = goodbit);
341_LIBCPP_HIDE_FROM_ABI void setstate(iostate __state);
342
343_LIBCPP_HIDE_FROM_ABI bool good() const;
344_LIBCPP_HIDE_FROM_ABI bool eof() const;
345_LIBCPP_HIDE_FROM_ABI bool fail() const;
346_LIBCPP_HIDE_FROM_ABI bool bad() const;
347
348_LIBCPP_HIDE_FROM_ABI iostate exceptions() const;
349_LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate);
350
351void __set_badbit_and_consider_rethrow();
352void __set_failbit_and_consider_rethrow();
353
354_LIBCPP_HIDE_FROM_ABI void __setstate_nothrow(iostate __state) {
355if (__rdbuf_)
356__rdstate_ |= __state;
357else
358__rdstate_ |= __state | ios_base::badbit;
359}
360
361protected:
362_LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(nullptr) {
363// Purposefully does no initialization
364//
365// Except for the locale, this is a sentinel to avoid destroying
366// an uninitialized object. See
367// test/libcxx/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
368// for the details.
369}
370
371void init(void* __sb);
372_LIBCPP_HIDE_FROM_ABI void* rdbuf() const { return __rdbuf_; }
373
374_LIBCPP_HIDE_FROM_ABI void rdbuf(void* __sb) {
375__rdbuf_ = __sb;
376clear();
377}
378
379void __call_callbacks(event);
380void copyfmt(const ios_base&);
381void move(ios_base&);
382void swap(ios_base&) _NOEXCEPT;
383
384_LIBCPP_HIDE_FROM_ABI void set_rdbuf(void* __sb) { __rdbuf_ = __sb; }
385
386private:
387// All data members must be scalars
388fmtflags __fmtflags_;
389streamsize __precision_;
390streamsize __width_;
391iostate __rdstate_;
392iostate __exceptions_;
393void* __rdbuf_;
394void* __loc_;
395event_callback* __fn_;
396int* __index_;
397size_t __event_size_;
398size_t __event_cap_;
399// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
400// enabled with clang.
401#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
402static atomic<int> __xindex_;
403#else
404static int __xindex_;
405#endif
406long* __iarray_;
407size_t __iarray_size_;
408size_t __iarray_cap_;
409void** __parray_;
410size_t __parray_size_;
411size_t __parray_cap_;
412};
413
414// enum class io_errc
415_LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1};
416_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
417
418template <>
419struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};
420
421#ifdef _LIBCPP_CXX03_LANG
422template <>
423struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};
424#endif
425
426_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;
427
428inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(io_errc __e) _NOEXCEPT {
429return error_code(static_cast<int>(__e), iostream_category());
430}
431
432inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(io_errc __e) _NOEXCEPT {
433return error_condition(static_cast<int>(__e), iostream_category());
434}
435
436class _LIBCPP_EXPORTED_FROM_ABI ios_base::failure : public system_error {
437public:
438explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
439explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
440_LIBCPP_HIDE_FROM_ABI failure(const failure&) _NOEXCEPT = default;
441~failure() _NOEXCEPT override;
442};
443
444_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {
445#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
446throw ios_base::failure(__msg);
447#else
448_LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
449#endif
450}
451
452class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {
453public:
454Init();
455~Init();
456};
457
458// fmtflags
459
460inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags() const { return __fmtflags_; }
461
462inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags(fmtflags __fmtfl) {
463fmtflags __r = __fmtflags_;
464__fmtflags_ = __fmtfl;
465return __r;
466}
467
468inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl) {
469fmtflags __r = __fmtflags_;
470__fmtflags_ |= __fmtfl;
471return __r;
472}
473
474inline _LIBCPP_HIDE_FROM_ABI void ios_base::unsetf(fmtflags __mask) { __fmtflags_ &= ~__mask; }
475
476inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl, fmtflags __mask) {
477fmtflags __r = __fmtflags_;
478unsetf(__mask);
479__fmtflags_ |= __fmtfl & __mask;
480return __r;
481}
482
483// precision
484
485inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision() const { return __precision_; }
486
487inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision(streamsize __prec) {
488streamsize __r = __precision_;
489__precision_ = __prec;
490return __r;
491}
492
493// width
494
495inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width() const { return __width_; }
496
497inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width(streamsize __wide) {
498streamsize __r = __width_;
499__width_ = __wide;
500return __r;
501}
502
503// iostate
504
505inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::rdstate() const { return __rdstate_; }
506
507inline _LIBCPP_HIDE_FROM_ABI void ios_base::setstate(iostate __state) { clear(__rdstate_ | __state); }
508
509inline _LIBCPP_HIDE_FROM_ABI bool ios_base::good() const { return __rdstate_ == 0; }
510
511inline _LIBCPP_HIDE_FROM_ABI bool ios_base::eof() const { return (__rdstate_ & eofbit) != 0; }
512
513inline _LIBCPP_HIDE_FROM_ABI bool ios_base::fail() const { return (__rdstate_ & (failbit | badbit)) != 0; }
514
515inline _LIBCPP_HIDE_FROM_ABI bool ios_base::bad() const { return (__rdstate_ & badbit) != 0; }
516
517inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::exceptions() const { return __exceptions_; }
518
519inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) {
520__exceptions_ = __iostate;
521clear(__rdstate_);
522}
523
524template <class _CharT, class _Traits>
525class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base {
526public:
527// types:
528typedef _CharT char_type;
529typedef _Traits traits_type;
530
531typedef typename traits_type::int_type int_type;
532typedef typename traits_type::pos_type pos_type;
533typedef typename traits_type::off_type off_type;
534
535static_assert(is_same<_CharT, typename traits_type::char_type>::value,
536"traits_type::char_type must be the same type as CharT");
537
538#ifdef _LIBCPP_CXX03_LANG
539// Preserve the ability to compare with literal 0,
540// and implicitly convert to bool, but not implicitly convert to int.
541_LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
542#else
543_LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
544#endif
545
546_LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
547_LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
548_LIBCPP_HIDE_FROM_ABI void clear(iostate __state = goodbit) { ios_base::clear(__state); }
549_LIBCPP_HIDE_FROM_ABI void setstate(iostate __state) { ios_base::setstate(__state); }
550_LIBCPP_HIDE_FROM_ABI bool good() const { return ios_base::good(); }
551_LIBCPP_HIDE_FROM_ABI bool eof() const { return ios_base::eof(); }
552_LIBCPP_HIDE_FROM_ABI bool fail() const { return ios_base::fail(); }
553_LIBCPP_HIDE_FROM_ABI bool bad() const { return ios_base::bad(); }
554
555_LIBCPP_HIDE_FROM_ABI iostate exceptions() const { return ios_base::exceptions(); }
556_LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate) { ios_base::exceptions(__iostate); }
557
558// 27.5.4.1 Constructor/destructor:
559_LIBCPP_HIDE_FROM_ABI explicit basic_ios(basic_streambuf<char_type, traits_type>* __sb);
560~basic_ios() override;
561
562// 27.5.4.2 Members:
563_LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie() const;
564_LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
565
566_LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf() const;
567_LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
568
569basic_ios& copyfmt(const basic_ios& __rhs);
570
571_LIBCPP_HIDE_FROM_ABI char_type fill() const;
572_LIBCPP_HIDE_FROM_ABI char_type fill(char_type __ch);
573
574_LIBCPP_HIDE_FROM_ABI locale imbue(const locale& __loc);
575
576_LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const;
577_LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const;
578
579protected:
580_LIBCPP_HIDE_FROM_ABI basic_ios() {
581// purposefully does no initialization
582// since the destructor does nothing this does not have ios_base issues.
583}
584_LIBCPP_HIDE_FROM_ABI void init(basic_streambuf<char_type, traits_type>* __sb);
585
586_LIBCPP_HIDE_FROM_ABI void move(basic_ios& __rhs);
587_LIBCPP_HIDE_FROM_ABI void move(basic_ios&& __rhs) { move(__rhs); }
588_LIBCPP_HIDE_FROM_ABI void swap(basic_ios& __rhs) _NOEXCEPT;
589_LIBCPP_HIDE_FROM_ABI void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
590
591private:
592basic_ostream<char_type, traits_type>* __tie_;
593mutable int_type __fill_;
594};
595
596template <class _CharT, class _Traits>
597inline _LIBCPP_HIDE_FROM_ABI basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type, traits_type>* __sb) {
598init(__sb);
599}
600
601template <class _CharT, class _Traits>
602basic_ios<_CharT, _Traits>::~basic_ios() {}
603
604template <class _CharT, class _Traits>
605inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {
606ios_base::init(__sb);
607__tie_ = nullptr;
608__fill_ = traits_type::eof();
609}
610
611template <class _CharT, class _Traits>
612inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie() const {
613return __tie_;
614}
615
616template <class _CharT, class _Traits>
617inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>*
618basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) {
619basic_ostream<char_type, traits_type>* __r = __tie_;
620__tie_ = __tiestr;
621return __r;
622}
623
624template <class _CharT, class _Traits>
625inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf() const {
626return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
627}
628
629template <class _CharT, class _Traits>
630inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>*
631basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) {
632basic_streambuf<char_type, traits_type>* __r = rdbuf();
633ios_base::rdbuf(__sb);
634return __r;
635}
636
637template <class _CharT, class _Traits>
638inline _LIBCPP_HIDE_FROM_ABI locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) {
639locale __r = getloc();
640ios_base::imbue(__loc);
641if (rdbuf())
642rdbuf()->pubimbue(__loc);
643return __r;
644}
645
646template <class _CharT, class _Traits>
647inline _LIBCPP_HIDE_FROM_ABI char basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const {
648return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
649}
650
651template <class _CharT, class _Traits>
652inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) const {
653return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
654}
655
656template <class _CharT, class _Traits>
657inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const {
658if (traits_type::eq_int_type(traits_type::eof(), __fill_))
659__fill_ = widen(' ');
660return __fill_;
661}
662
663template <class _CharT, class _Traits>
664inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) {
665if (traits_type::eq_int_type(traits_type::eof(), __fill_))
666__fill_ = widen(' ');
667char_type __r = __fill_;
668__fill_ = __ch;
669return __r;
670}
671
672template <class _CharT, class _Traits>
673basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) {
674if (this != &__rhs) {
675__call_callbacks(erase_event);
676ios_base::copyfmt(__rhs);
677__tie_ = __rhs.__tie_;
678__fill_ = __rhs.__fill_;
679__call_callbacks(copyfmt_event);
680exceptions(__rhs.exceptions());
681}
682return *this;
683}
684
685template <class _CharT, class _Traits>
686inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) {
687ios_base::move(__rhs);
688__tie_ = __rhs.__tie_;
689__rhs.__tie_ = nullptr;
690__fill_ = __rhs.__fill_;
691}
692
693template <class _CharT, class _Traits>
694inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT {
695ios_base::swap(__rhs);
696std::swap(__tie_, __rhs.__tie_);
697std::swap(__fill_, __rhs.__fill_);
698}
699
700template <class _CharT, class _Traits>
701inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) {
702ios_base::set_rdbuf(__sb);
703}
704
705extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
706
707#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
708extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
709#endif
710
711_LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {
712__str.setf(ios_base::boolalpha);
713return __str;
714}
715
716_LIBCPP_HIDE_FROM_ABI inline ios_base& noboolalpha(ios_base& __str) {
717__str.unsetf(ios_base::boolalpha);
718return __str;
719}
720
721_LIBCPP_HIDE_FROM_ABI inline ios_base& showbase(ios_base& __str) {
722__str.setf(ios_base::showbase);
723return __str;
724}
725
726_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowbase(ios_base& __str) {
727__str.unsetf(ios_base::showbase);
728return __str;
729}
730
731_LIBCPP_HIDE_FROM_ABI inline ios_base& showpoint(ios_base& __str) {
732__str.setf(ios_base::showpoint);
733return __str;
734}
735
736_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpoint(ios_base& __str) {
737__str.unsetf(ios_base::showpoint);
738return __str;
739}
740
741_LIBCPP_HIDE_FROM_ABI inline ios_base& showpos(ios_base& __str) {
742__str.setf(ios_base::showpos);
743return __str;
744}
745
746_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpos(ios_base& __str) {
747__str.unsetf(ios_base::showpos);
748return __str;
749}
750
751_LIBCPP_HIDE_FROM_ABI inline ios_base& skipws(ios_base& __str) {
752__str.setf(ios_base::skipws);
753return __str;
754}
755
756_LIBCPP_HIDE_FROM_ABI inline ios_base& noskipws(ios_base& __str) {
757__str.unsetf(ios_base::skipws);
758return __str;
759}
760
761_LIBCPP_HIDE_FROM_ABI inline ios_base& uppercase(ios_base& __str) {
762__str.setf(ios_base::uppercase);
763return __str;
764}
765
766_LIBCPP_HIDE_FROM_ABI inline ios_base& nouppercase(ios_base& __str) {
767__str.unsetf(ios_base::uppercase);
768return __str;
769}
770
771_LIBCPP_HIDE_FROM_ABI inline ios_base& unitbuf(ios_base& __str) {
772__str.setf(ios_base::unitbuf);
773return __str;
774}
775
776_LIBCPP_HIDE_FROM_ABI inline ios_base& nounitbuf(ios_base& __str) {
777__str.unsetf(ios_base::unitbuf);
778return __str;
779}
780
781_LIBCPP_HIDE_FROM_ABI inline ios_base& internal(ios_base& __str) {
782__str.setf(ios_base::internal, ios_base::adjustfield);
783return __str;
784}
785
786_LIBCPP_HIDE_FROM_ABI inline ios_base& left(ios_base& __str) {
787__str.setf(ios_base::left, ios_base::adjustfield);
788return __str;
789}
790
791_LIBCPP_HIDE_FROM_ABI inline ios_base& right(ios_base& __str) {
792__str.setf(ios_base::right, ios_base::adjustfield);
793return __str;
794}
795
796_LIBCPP_HIDE_FROM_ABI inline ios_base& dec(ios_base& __str) {
797__str.setf(ios_base::dec, ios_base::basefield);
798return __str;
799}
800
801_LIBCPP_HIDE_FROM_ABI inline ios_base& hex(ios_base& __str) {
802__str.setf(ios_base::hex, ios_base::basefield);
803return __str;
804}
805
806_LIBCPP_HIDE_FROM_ABI inline ios_base& oct(ios_base& __str) {
807__str.setf(ios_base::oct, ios_base::basefield);
808return __str;
809}
810
811_LIBCPP_HIDE_FROM_ABI inline ios_base& fixed(ios_base& __str) {
812__str.setf(ios_base::fixed, ios_base::floatfield);
813return __str;
814}
815
816_LIBCPP_HIDE_FROM_ABI inline ios_base& scientific(ios_base& __str) {
817__str.setf(ios_base::scientific, ios_base::floatfield);
818return __str;
819}
820
821_LIBCPP_HIDE_FROM_ABI inline ios_base& hexfloat(ios_base& __str) {
822__str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
823return __str;
824}
825
826_LIBCPP_HIDE_FROM_ABI inline ios_base& defaultfloat(ios_base& __str) {
827__str.unsetf(ios_base::floatfield);
828return __str;
829}
830
831_LIBCPP_END_NAMESPACE_STD
832
833_LIBCPP_POP_MACROS
834
835#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
836# include <atomic>
837# include <concepts>
838# include <cstddef>
839# include <cstdlib>
840# include <cstring>
841# include <initializer_list>
842# include <limits>
843# include <mutex>
844# include <new>
845# include <stdexcept>
846# include <system_error>
847# include <type_traits>
848# include <typeinfo>
849#endif
850
851#endif // _LIBCPP_IOS
852