1 // Iostreams base classes -*- C++ -*-
3 // Copyright (C) 1997-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file bits/ios_base.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{ios}
31 // ISO C++ 14882: 27.4 Iostreams base classes
37 #ifdef _GLIBCXX_SYSHDR
38 #pragma GCC system_header
41 #include <ext/atomicity.h>
42 #include <bits/localefwd.h>
43 #include <bits/locale_classes.h>
45 #if __cplusplus < 201103L
48 # include <system_error>
51 namespace std
_GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 // The following definitions of bitmask types are enums, not ints,
56 // as permitted (but not required) in the standard, in order to provide
57 // better type safety in iostream calls. A side effect is that in C++98
58 // expressions involving them are not compile-time constants.
61 _S_boolalpha
= 1L << 0,
65 _S_internal
= 1L << 4,
69 _S_scientific
= 1L << 8,
70 _S_showbase
= 1L << 9,
71 _S_showpoint
= 1L << 10,
72 _S_showpos
= 1L << 11,
74 _S_unitbuf
= 1L << 13,
75 _S_uppercase
= 1L << 14,
76 _S_adjustfield
= _S_left
| _S_right
| _S_internal
,
77 _S_basefield
= _S_dec
| _S_oct
| _S_hex
,
78 _S_floatfield
= _S_scientific
| _S_fixed
,
79 _S_ios_fmtflags_end
= 1L << 16,
80 _S_ios_fmtflags_max
= __INT_MAX__
,
81 _S_ios_fmtflags_min
= ~__INT_MAX__
84 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
86 operator&(_Ios_Fmtflags __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
87 { return _Ios_Fmtflags(static_cast<int>(__a
) & static_cast<int>(__b
)); }
89 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
91 operator|(_Ios_Fmtflags __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
92 { return _Ios_Fmtflags(static_cast<int>(__a
) | static_cast<int>(__b
)); }
94 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
96 operator^(_Ios_Fmtflags __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
97 { return _Ios_Fmtflags(static_cast<int>(__a
) ^ static_cast<int>(__b
)); }
99 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
101 operator~(_Ios_Fmtflags __a
) _GLIBCXX_NOTHROW
102 { return _Ios_Fmtflags(~static_cast<int>(__a
)); }
105 inline const _Ios_Fmtflags
&
106 operator|=(_Ios_Fmtflags
& __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
107 { return __a
= __a
| __b
; }
110 inline const _Ios_Fmtflags
&
111 operator&=(_Ios_Fmtflags
& __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
112 { return __a
= __a
& __b
; }
115 inline const _Ios_Fmtflags
&
116 operator^=(_Ios_Fmtflags
& __a
, _Ios_Fmtflags __b
) _GLIBCXX_NOTHROW
117 { return __a
= __a
^ __b
; }
119 // If std::ios_base::noreplace isn't available, -Wswitch should ignore
121 #ifdef __glibcxx_ios_noreplace
122 #define _NOREPLACE_UNUSED
124 #define _NOREPLACE_UNUSED __attribute__((__unused__))
127 enum __attribute__((__flag_enum__
)) _Ios_Openmode
135 _S_noreplace _NOREPLACE_UNUSED
= 1L << 6,
136 _S_ios_openmode_end
__attribute__((__unused__
)) = 1L << 16,
137 _S_ios_openmode_max
__attribute__((__unused__
)) = __INT_MAX__
,
138 _S_ios_openmode_min
__attribute__((__unused__
)) = ~__INT_MAX__
141 #undef _NOREPLACE_UNUSED
143 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
145 operator&(_Ios_Openmode __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
146 { return _Ios_Openmode(static_cast<int>(__a
) & static_cast<int>(__b
)); }
148 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
150 operator|(_Ios_Openmode __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
151 { return _Ios_Openmode(static_cast<int>(__a
) | static_cast<int>(__b
)); }
153 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
155 operator^(_Ios_Openmode __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
156 { return _Ios_Openmode(static_cast<int>(__a
) ^ static_cast<int>(__b
)); }
158 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
160 operator~(_Ios_Openmode __a
) _GLIBCXX_NOTHROW
161 { return _Ios_Openmode(~static_cast<int>(__a
)); }
164 inline const _Ios_Openmode
&
165 operator|=(_Ios_Openmode
& __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
166 { return __a
= __a
| __b
; }
169 inline const _Ios_Openmode
&
170 operator&=(_Ios_Openmode
& __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
171 { return __a
= __a
& __b
; }
174 inline const _Ios_Openmode
&
175 operator^=(_Ios_Openmode
& __a
, _Ios_Openmode __b
) _GLIBCXX_NOTHROW
176 { return __a
= __a
^ __b
; }
184 _S_failbit
= 1L << 2,
185 _S_ios_iostate_end
= 1L << 16,
186 _S_ios_iostate_max
= __INT_MAX__
,
187 _S_ios_iostate_min
= ~__INT_MAX__
190 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
192 operator&(_Ios_Iostate __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
193 { return _Ios_Iostate(static_cast<int>(__a
) & static_cast<int>(__b
)); }
195 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
197 operator|(_Ios_Iostate __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
198 { return _Ios_Iostate(static_cast<int>(__a
) | static_cast<int>(__b
)); }
200 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
202 operator^(_Ios_Iostate __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
203 { return _Ios_Iostate(static_cast<int>(__a
) ^ static_cast<int>(__b
)); }
205 _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
207 operator~(_Ios_Iostate __a
) _GLIBCXX_NOTHROW
208 { return _Ios_Iostate(~static_cast<int>(__a
)); }
211 inline const _Ios_Iostate
&
212 operator|=(_Ios_Iostate
& __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
213 { return __a
= __a
| __b
; }
216 inline const _Ios_Iostate
&
217 operator&=(_Ios_Iostate
& __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
218 { return __a
= __a
& __b
; }
221 inline const _Ios_Iostate
&
222 operator^=(_Ios_Iostate
& __a
, _Ios_Iostate __b
) _GLIBCXX_NOTHROW
223 { return __a
= __a
^ __b
; }
229 _S_cur
= _GLIBCXX_STDIO_SEEK_CUR
,
230 _S_end
= _GLIBCXX_STDIO_SEEK_END
,
231 _S_ios_seekdir_end
= 1L << 16
234 #if __cplusplus >= 201103L
236 enum class io_errc
{ stream
= 1 };
238 template <> struct is_error_code_enum
<io_errc
> : public true_type
{ };
240 [[__nodiscard__
, __gnu__::__const__
]]
241 const error_category
&
242 iostream_category() noexcept
;
246 make_error_code(io_errc __e
) noexcept
247 { return error_code(static_cast<int>(__e
), iostream_category()); }
250 inline error_condition
251 make_error_condition(io_errc __e
) noexcept
252 { return error_condition(static_cast<int>(__e
), iostream_category()); }
255 // 27.4.2 Class ios_base
257 * @brief The base of the I/O class hierarchy.
260 * This class defines everything that can be defined about I/O that does
261 * not depend on the type of characters being input or output. Most
262 * people will only see @c ios_base when they need to specify the full
263 * name of the various I/O flags (e.g., the openmodes).
267 #if _GLIBCXX_USE_CXX11_ABI
268 #if __cplusplus < 201103L
269 // Type that is layout-compatible with std::system_error
270 struct system_error
: std::runtime_error
272 // Type that is layout-compatible with std::error_code
286 * @brief These are thrown to indicate problems with io.
287 * @ingroup exceptions
289 * 27.4.2.1.1 Class ios_base::failure
291 #if _GLIBCXX_USE_CXX11_ABI
292 class _GLIBCXX_ABI_TAG_CXX11 failure
: public system_error
296 failure(const string
& __str
);
298 #if __cplusplus >= 201103L
300 failure(const string
&, const error_code
&);
303 failure(const char*, const error_code
& = io_errc::stream
);
310 what() const throw();
313 class failure
: public exception
316 // _GLIBCXX_RESOLVE_LIB_DEFECTS
317 // 48. Use of non-existent exception constructor
319 failure(const string
& __str
) throw();
321 // This declaration is not useless:
322 // http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html
327 what() const throw();
329 #if __cplusplus >= 201103L
330 // Define the new members required by C++11,
331 // even though the error_code cannot be stored.
334 failure(const string
& __s
, const error_code
&) noexcept
339 failure(const char* __s
, const error_code
& = error_code
{})
340 : failure(string(__s
))
343 // Stand-in for system_error::code() but returning by value.
344 error_code
code() const noexcept
{ return error_code
{}; }
352 // 27.4.2.1.2 Type ios_base::fmtflags
354 * @brief This is a bitmask type.
356 * @c @a _Ios_Fmtflags is implementation-defined, but it is valid to
357 * perform bitwise operations on these values and expect the Right
358 * Thing to happen. Defined objects of type fmtflags are:
378 typedef _Ios_Fmtflags fmtflags
;
380 /// Insert/extract @c bool in alphabetic rather than numeric format.
381 static const fmtflags boolalpha
= _S_boolalpha
;
383 /// Converts integer input or generates integer output in decimal base.
384 static const fmtflags dec
= _S_dec
;
386 /// Generate floating-point output in fixed-point notation.
387 static const fmtflags fixed
= _S_fixed
;
389 /// Converts integer input or generates integer output in hexadecimal base.
390 static const fmtflags hex
= _S_hex
;
392 /// Adds fill characters at a designated internal point in certain
393 /// generated output, or identical to @c right if no such point is
395 static const fmtflags internal
= _S_internal
;
397 /// Adds fill characters on the right (final positions) of certain
398 /// generated output. (I.e., the thing you print is flush left.)
399 static const fmtflags left
= _S_left
;
401 /// Converts integer input or generates integer output in octal base.
402 static const fmtflags oct
= _S_oct
;
404 /// Adds fill characters on the left (initial positions) of certain
405 /// generated output. (I.e., the thing you print is flush right.)
406 static const fmtflags right
= _S_right
;
408 /// Generates floating-point output in scientific notation.
409 static const fmtflags scientific
= _S_scientific
;
411 /// Generates a prefix indicating the numeric base of generated integer
413 static const fmtflags showbase
= _S_showbase
;
415 /// Generates a decimal-point character unconditionally in generated
416 /// floating-point output.
417 static const fmtflags showpoint
= _S_showpoint
;
419 /// Generates a + sign in non-negative generated numeric output.
420 static const fmtflags showpos
= _S_showpos
;
422 /// Skips leading white space before certain input operations.
423 static const fmtflags skipws
= _S_skipws
;
425 /// Flushes output after each output operation.
426 static const fmtflags unitbuf
= _S_unitbuf
;
428 /// Replaces certain lowercase letters with their uppercase equivalents
429 /// in generated output.
430 static const fmtflags uppercase
= _S_uppercase
;
432 /// A mask of left|right|internal. Useful for the 2-arg form of @c setf.
433 static const fmtflags adjustfield
= _S_adjustfield
;
435 /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf.
436 static const fmtflags basefield
= _S_basefield
;
438 /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf.
439 static const fmtflags floatfield
= _S_floatfield
;
441 // 27.4.2.1.3 Type ios_base::iostate
443 * @brief This is a bitmask type.
445 * @c @a _Ios_Iostate is implementation-defined, but it is valid to
446 * perform bitwise operations on these values and expect the Right
447 * Thing to happen. Defined objects of type iostate are:
453 typedef _Ios_Iostate iostate
;
455 /// Indicates a loss of integrity in an input or output sequence (such
456 /// as an irrecoverable read error from a file).
457 static const iostate badbit
= _S_badbit
;
459 /// Indicates that an input operation reached the end of an input sequence.
460 static const iostate eofbit
= _S_eofbit
;
462 /// Indicates that an input operation failed to read the expected
463 /// characters, or that an output operation failed to generate the
464 /// desired characters.
465 static const iostate failbit
= _S_failbit
;
467 /// Indicates all is well.
468 static const iostate goodbit
= _S_goodbit
;
470 // 27.4.2.1.4 Type ios_base::openmode
472 * @brief This is a bitmask type.
474 * @c @a _Ios_Openmode is implementation-defined, but it is valid to
475 * perform bitwise operations on these values and expect the Right
476 * Thing to happen. Defined objects of type openmode are:
484 typedef _Ios_Openmode openmode
;
486 /// Seek to end before each write.
487 static const openmode app
= _S_app
;
489 /// Open and seek to end immediately after opening.
490 static const openmode ate
= _S_ate
;
492 /// Perform input and output in binary mode (as opposed to text mode).
493 /// This is probably not what you think it is; see
494 /// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
495 static const openmode binary
= _S_bin
;
497 /// Open for input. Default for @c ifstream and fstream.
498 static const openmode in
= _S_in
;
500 /// Open for output. Default for @c ofstream and fstream.
501 static const openmode out
= _S_out
;
503 /// Truncate an existing stream when opening. Default for @c ofstream.
504 static const openmode trunc
= _S_trunc
;
506 static const openmode __noreplace
= _S_noreplace
;
508 #ifdef __glibcxx_ios_noreplace // C++ >= 23 && HOSTED
509 /// Open a file in exclusive mode.
510 static const openmode noreplace
= _S_noreplace
;
513 // 27.4.2.1.5 Type ios_base::seekdir
515 * @brief This is an enumerated type.
517 * @c @a _Ios_Seekdir is implementation-defined. Defined values
518 * of type seekdir are:
520 * - cur, equivalent to @c SEEK_CUR in the C standard library.
521 * - end, equivalent to @c SEEK_END in the C standard library.
523 typedef _Ios_Seekdir seekdir
;
525 /// Request a seek relative to the beginning of the stream.
526 static const seekdir beg
= _S_beg
;
528 /// Request a seek relative to the current position within the sequence.
529 static const seekdir cur
= _S_cur
;
531 /// Request a seek relative to the current end of the sequence.
532 static const seekdir end
= _S_end
;
534 #if __cplusplus <= 201402L
535 // Annex D.6 (removed in C++17)
537 _GLIBCXX_DEPRECATED_SUGGEST("std::iostate");
538 typedef int open_mode
539 _GLIBCXX_DEPRECATED_SUGGEST("std::openmode");
541 _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir");
543 typedef std::streampos streampos
544 _GLIBCXX_DEPRECATED_SUGGEST("std::streampos");
545 typedef std::streamoff streamoff
546 _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff");
551 * @brief The set of events that may be passed to an event callback.
553 * erase_event is used during ~ios() and copyfmt(). imbue_event is used
554 * during imbue(). copyfmt_event is used during copyfmt().
564 * @brief The type of an event callback function.
565 * @param __e One of the members of the event enum.
566 * @param __b Reference to the ios_base object.
567 * @param __i The integer provided when the callback was registered.
569 * Event callbacks are user defined functions that get called during
570 * several ios_base and basic_ios functions, specifically imbue(),
571 * copyfmt(), and ~ios().
573 typedef void (*event_callback
) (event __e
, ios_base
& __b
, int __i
);
576 * @brief Add the callback __fn with parameter __index.
577 * @param __fn The function to add.
578 * @param __index The integer to pass to the function when invoked.
580 * Registers a function as an event callback with an integer parameter to
581 * be passed to the function when invoked. Multiple copies of the
582 * function are allowed. If there are multiple callbacks, they are
583 * invoked in the order they were registered.
586 register_callback(event_callback __fn
, int __index
);
589 streamsize _M_precision
;
592 iostate _M_exception
;
593 iostate _M_streambuf_state
;
595 // 27.4.2.6 Members for callbacks
596 // 27.4.2.6 ios_base callbacks
597 struct _Callback_list
600 _Callback_list
* _M_next
;
601 ios_base::event_callback _M_fn
;
603 _Atomic_word _M_refcount
; // 0 means one reference.
605 _Callback_list(ios_base::event_callback __fn
, int __index
,
606 _Callback_list
* __cb
)
607 : _M_next(__cb
), _M_fn(__fn
), _M_index(__index
), _M_refcount(0) { }
610 _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount
, 1); }
612 // 0 => OK to delete.
614 _M_remove_reference()
616 // Be race-detector-friendly. For more info see bits/c++config.
617 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount
);
618 int __res
= __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount
, -1);
621 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount
);
627 _Callback_list
* _M_callbacks
;
630 _M_call_callbacks(event __ev
) throw();
633 _M_dispose_callbacks(void) throw();
635 // 27.4.2.5 Members for iword/pword storage
640 _Words() : _M_pword(0), _M_iword(0) { }
643 // Only for failed iword/pword calls.
646 // Guaranteed storage.
647 // The first 5 iword and pword slots are reserved for internal use.
648 enum { _S_local_word_size
= 8 };
649 _Words _M_local_word
[_S_local_word_size
];
651 // Allocated storage.
656 _M_grow_words(int __index
, bool __iword
);
658 // Members for locale and locale caching.
659 locale _M_ios_locale
;
666 // 27.4.2.1.6 Class ios_base::Init
667 // Used to initialize standard streams. In theory, g++ could use
668 // -finit-priority to order this stuff correctly without going
669 // through these machinations.
672 friend class ios_base
;
677 #if __cplusplus >= 201103L
678 Init(const Init
&) = default;
679 Init
& operator=(const Init
&) = default;
683 static _Atomic_word _S_refcount
;
684 static bool _S_synced_with_stdio
;
687 // [27.4.2.2] fmtflags state functions
689 * @brief Access to format flags.
690 * @return The format control flags for both input and output.
698 * @brief Setting new format flags all at once.
699 * @param __fmtfl The new flags to set.
700 * @return The previous format control flags.
702 * This function overwrites all the format flags with @a __fmtfl.
705 flags(fmtflags __fmtfl
)
707 fmtflags __old
= _M_flags
;
713 * @brief Setting new format flags.
714 * @param __fmtfl Additional flags to set.
715 * @return The previous format control flags.
717 * This function sets additional flags in format control. Flags that
718 * were previously set remain set.
721 setf(fmtflags __fmtfl
)
723 fmtflags __old
= _M_flags
;
729 * @brief Setting new format flags.
730 * @param __fmtfl Additional flags to set.
731 * @param __mask The flags mask for @a fmtfl.
732 * @return The previous format control flags.
734 * This function clears @a mask in the format flags, then sets
735 * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield.
738 setf(fmtflags __fmtfl
, fmtflags __mask
)
740 fmtflags __old
= _M_flags
;
742 _M_flags
|= (__fmtfl
& __mask
);
747 * @brief Clearing format flags.
748 * @param __mask The flags to unset.
750 * This function clears @a __mask in the format flags.
753 unsetf(fmtflags __mask
)
754 { _M_flags
&= ~__mask
; }
757 * @brief Flags access.
758 * @return The precision to generate on certain output operations.
760 * Be careful if you try to give a definition of @a precision here; see
766 { return _M_precision
; }
769 * @brief Changing flags.
770 * @param __prec The new precision value.
771 * @return The previous value of precision().
774 precision(streamsize __prec
)
776 streamsize __old
= _M_precision
;
777 _M_precision
= __prec
;
782 * @brief Flags access.
783 * @return The minimum field width to generate on output operations.
785 * <em>Minimum field width</em> refers to the number of characters.
793 * @brief Changing flags.
794 * @param __wide The new width value.
795 * @return The previous value of width().
798 width(streamsize __wide
)
800 streamsize __old
= _M_width
;
805 // [27.4.2.4] ios_base static members
807 * @brief Interaction with the standard C I/O objects.
808 * @param __sync Whether to synchronize or not.
809 * @return True if the standard streams were previously synchronized.
811 * The synchronization referred to is @e only that between the standard
812 * C facilities (e.g., stdout) and the standard C++ objects (e.g.,
813 * cout). User-declared streams are unaffected. See
814 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
817 sync_with_stdio(bool __sync
= true);
819 // [27.4.2.3] ios_base locale functions
821 * @brief Setting a new locale.
822 * @param __loc The new locale.
823 * @return The previous locale.
825 * Sets the new locale for this stream, and then invokes each callback
829 imbue(const locale
& __loc
) throw();
832 * @brief Locale access
833 * @return A copy of the current locale.
835 * If @c imbue(loc) has previously been called, then this function
836 * returns @c loc. Otherwise, it returns a copy of @c std::locale(),
837 * the global C++ locale.
842 { return _M_ios_locale
; }
845 * @brief Locale access
846 * @return A reference to the current locale.
848 * Like getloc above, but returns a reference instead of
853 { return _M_ios_locale
; }
855 // [27.4.2.5] ios_base storage functions
857 * @brief Access to unique indices.
858 * @return An integer different from all previous calls.
860 * This function returns a unique integer every time it is called. It
861 * can be used for any purpose, but is primarily intended to be a unique
862 * index for the iword and pword functions. The expectation is that an
863 * application calls xalloc in order to obtain an index in the iword and
864 * pword arrays that can be used without fear of conflict.
866 * The implementation maintains a static variable that is incremented and
867 * returned on each invocation. xalloc is guaranteed to return an index
868 * that is safe to use in the iword and pword arrays.
874 * @brief Access to integer array.
875 * @param __ix Index into the array.
876 * @return A reference to an integer associated with the index.
878 * The iword function provides access to an array of integers that can be
879 * used for any purpose. The array grows as required to hold the
880 * supplied index. All integers in the array are initialized to 0.
882 * The implementation reserves several indices. You should use xalloc to
883 * obtain an index that is safe to use. Also note that since the array
884 * can grow dynamically, it is not safe to hold onto the reference.
889 _Words
& __word
= ((unsigned)__ix
< (unsigned)_M_word_size
)
890 ? _M_word
[__ix
] : _M_grow_words(__ix
, true);
891 return __word
._M_iword
;
895 * @brief Access to void pointer array.
896 * @param __ix Index into the array.
897 * @return A reference to a void* associated with the index.
899 * The pword function provides access to an array of pointers that can be
900 * used for any purpose. The array grows as required to hold the
901 * supplied index. All pointers in the array are initialized to 0.
903 * The implementation reserves several indices. You should use xalloc to
904 * obtain an index that is safe to use. Also note that since the array
905 * can grow dynamically, it is not safe to hold onto the reference.
910 _Words
& __word
= ((unsigned)__ix
< (unsigned)_M_word_size
)
911 ? _M_word
[__ix
] : _M_grow_words(__ix
, false);
912 return __word
._M_pword
;
917 * Invokes each callback with erase_event. Destroys local storage.
919 * Note that the ios_base object for the standard streams never gets
920 * destroyed. As a result, any callbacks registered with the standard
921 * streams will not get invoked with erase_event (unless copyfmt is
929 #if __cplusplus < 201103L
930 // _GLIBCXX_RESOLVE_LIB_DEFECTS
931 // 50. Copy constructor and assignment operator of ios_base
933 ios_base(const ios_base
&);
936 operator=(const ios_base
&);
939 ios_base(const ios_base
&) = delete;
942 operator=(const ios_base
&) = delete;
946 _M_move(ios_base
&) noexcept
;
949 _M_swap(ios_base
& __rhs
) noexcept
;
953 // [27.4.5.1] fmtflags manipulators
954 /// Calls base.setf(ios_base::boolalpha).
956 boolalpha(ios_base
& __base
)
958 __base
.setf(ios_base::boolalpha
);
962 /// Calls base.unsetf(ios_base::boolalpha).
964 noboolalpha(ios_base
& __base
)
966 __base
.unsetf(ios_base::boolalpha
);
970 /// Calls base.setf(ios_base::showbase).
972 showbase(ios_base
& __base
)
974 __base
.setf(ios_base::showbase
);
978 /// Calls base.unsetf(ios_base::showbase).
980 noshowbase(ios_base
& __base
)
982 __base
.unsetf(ios_base::showbase
);
986 /// Calls base.setf(ios_base::showpoint).
988 showpoint(ios_base
& __base
)
990 __base
.setf(ios_base::showpoint
);
994 /// Calls base.unsetf(ios_base::showpoint).
996 noshowpoint(ios_base
& __base
)
998 __base
.unsetf(ios_base::showpoint
);
1002 /// Calls base.setf(ios_base::showpos).
1004 showpos(ios_base
& __base
)
1006 __base
.setf(ios_base::showpos
);
1010 /// Calls base.unsetf(ios_base::showpos).
1012 noshowpos(ios_base
& __base
)
1014 __base
.unsetf(ios_base::showpos
);
1018 /// Calls base.setf(ios_base::skipws).
1020 skipws(ios_base
& __base
)
1022 __base
.setf(ios_base::skipws
);
1026 /// Calls base.unsetf(ios_base::skipws).
1028 noskipws(ios_base
& __base
)
1030 __base
.unsetf(ios_base::skipws
);
1034 /// Calls base.setf(ios_base::uppercase).
1036 uppercase(ios_base
& __base
)
1038 __base
.setf(ios_base::uppercase
);
1042 /// Calls base.unsetf(ios_base::uppercase).
1044 nouppercase(ios_base
& __base
)
1046 __base
.unsetf(ios_base::uppercase
);
1050 /// Calls base.setf(ios_base::unitbuf).
1052 unitbuf(ios_base
& __base
)
1054 __base
.setf(ios_base::unitbuf
);
1058 /// Calls base.unsetf(ios_base::unitbuf).
1060 nounitbuf(ios_base
& __base
)
1062 __base
.unsetf(ios_base::unitbuf
);
1066 // [27.4.5.2] adjustfield manipulators
1067 /// Calls base.setf(ios_base::internal, ios_base::adjustfield).
1069 internal(ios_base
& __base
)
1071 __base
.setf(ios_base::internal
, ios_base::adjustfield
);
1075 /// Calls base.setf(ios_base::left, ios_base::adjustfield).
1077 left(ios_base
& __base
)
1079 __base
.setf(ios_base::left
, ios_base::adjustfield
);
1083 /// Calls base.setf(ios_base::right, ios_base::adjustfield).
1085 right(ios_base
& __base
)
1087 __base
.setf(ios_base::right
, ios_base::adjustfield
);
1091 // [27.4.5.3] basefield manipulators
1092 /// Calls base.setf(ios_base::dec, ios_base::basefield).
1094 dec(ios_base
& __base
)
1096 __base
.setf(ios_base::dec
, ios_base::basefield
);
1100 /// Calls base.setf(ios_base::hex, ios_base::basefield).
1102 hex(ios_base
& __base
)
1104 __base
.setf(ios_base::hex
, ios_base::basefield
);
1108 /// Calls base.setf(ios_base::oct, ios_base::basefield).
1110 oct(ios_base
& __base
)
1112 __base
.setf(ios_base::oct
, ios_base::basefield
);
1116 // [27.4.5.4] floatfield manipulators
1117 /// Calls base.setf(ios_base::fixed, ios_base::floatfield).
1119 fixed(ios_base
& __base
)
1121 __base
.setf(ios_base::fixed
, ios_base::floatfield
);
1125 /// Calls base.setf(ios_base::scientific, ios_base::floatfield).
1127 scientific(ios_base
& __base
)
1129 __base
.setf(ios_base::scientific
, ios_base::floatfield
);
1133 #if __cplusplus >= 201103L
1134 // New C++11 floatfield manipulators
1137 /// base.setf(ios_base::fixed|ios_base::scientific, ios_base::floatfield)
1139 hexfloat(ios_base
& __base
)
1141 __base
.setf(ios_base::fixed
| ios_base::scientific
, ios_base::floatfield
);
1145 /// Calls @c base.unsetf(ios_base::floatfield)
1147 defaultfloat(ios_base
& __base
)
1149 __base
.unsetf(ios_base::floatfield
);
1154 _GLIBCXX_END_NAMESPACE_VERSION
1157 #endif /* _IOS_BASE_H */