CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 22:48:18 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/ios/ios_base/fmtflags/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 22:48:18 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"9a19-VoUaQV1fEHjrp9IY4A2ZuLzfiKI"
Content-Encoding: gzip
Bitmask type to represent stream format flags.
This type is used as its parameter and/or return value by the member functions flags, setf and unsetf.
The values passed and retrieved by these functions can be any valid combination of the following member constants:
Three additional bitmask constants made of the combination of the values of each of the three groups of selective flags can also be used:
The values of these constants can be combined into a single fmtflags value using the OR bitwise operator (|).
These constants are defined as public members in the ios_base class. Therefore, they can be refered to either directly by their name as ios_base members (like ios_base::hex) or by using any of their inherited classes or instantiated objects, like for example
These values of type ios_base::fmtflags should not be confused with the manipulators that have the same name but in the global scope, because they are used in different circumstances. The manipulators cannot be used as values for ios_base::fmtflags, as well as these constants shouldn't be used instead of the manipulators. Notice the difference:
Notice that several manipulators have the same name as these member constants (but as global functions instead) - see manipulators. The behavior of these manipulators generally corresponds to the same as setting or unsetting them with ios_base::setf or ios_base::unsetf, but they should not be confused! Manipulators are global functions and these constants are member constants. For example, showbase is a manipulator, while ios_base::showbase is a constant value that can be used as parameter with ios_base::setf.
The code shows some different ways of printing the same result, using both the fmtflags member constants and their homonymous manipulators.
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<ios>
types
manipulators
other functions
-
iostream_categoryC++11
-
ios_base
- ios_base::~ios_base
- ios_base::ios_base
member functions
member types
public member type
<ios> <iostream>
std::ios_base::fmtflags
Type for stream format flags
This type is used as its parameter and/or return value by the member functions flags, setf and unsetf.
The values passed and retrieved by these functions can be any valid combination of the following member constants:
field | member constant | effect when set |
---|---|---|
independent flags | boolalpha | read/write bool elements as alphabetic strings (true and false ). |
showbase | write integral values preceded by their corresponding numeric base prefix. | |
showpoint | write floating-point values including always the decimal point. | |
showpos | write non-negative numerical values preceded by a plus sign (+). | |
skipws | skip leading whitespaces on certain input operations. | |
unitbuf | flush output after each inserting operation. | |
uppercase | write uppercase letters replacing lowercase letters in certain insertion operations. | |
numerical base (basefield) | dec | read/write integral values using decimal base format. |
hex | read/write integral values using hexadecimal base format. | |
oct | read/write integral values using octal base format. | |
float format (floatfield) | fixed | write floating point values in fixed-point notation. |
scientific | write floating-point values in scientific notation. | |
adjustment (adjustfield) | internal | the output is padded to the field width by inserting fill characters at a specified internal point. |
left | the output is padded to the field width appending fill characters at the end. | |
right | the output is padded to the field width by inserting fill characters at the beginning. |
Three additional bitmask constants made of the combination of the values of each of the three groups of selective flags can also be used:
flag value | equivalent to |
---|---|
adjustfield | left | right | internal |
basefield | dec | oct | hex |
floatfield | scientific | fixed |
The values of these constants can be combined into a single fmtflags value using the OR bitwise operator (|).
These constants are defined as public members in the ios_base class. Therefore, they can be refered to either directly by their name as ios_base members (like ios_base::hex) or by using any of their inherited classes or instantiated objects, like for example
ios::left
or cout.oct
.These values of type ios_base::fmtflags should not be confused with the manipulators that have the same name but in the global scope, because they are used in different circumstances. The manipulators cannot be used as values for ios_base::fmtflags, as well as these constants shouldn't be used instead of the manipulators. Notice the difference:
|
|
Notice that several manipulators have the same name as these member constants (but as global functions instead) - see manipulators. The behavior of these manipulators generally corresponds to the same as setting or unsetting them with ios_base::setf or ios_base::unsetf, but they should not be confused! Manipulators are global functions and these constants are member constants. For example, showbase is a manipulator, while ios_base::showbase is a constant value that can be used as parameter with ios_base::setf.
Example
|
|
The code shows some different ways of printing the same result, using both the fmtflags member constants and their homonymous manipulators.
Output:
0x64 0x64 0x64 0x64 0x64 |
See also
- ios_base::flags
- Get/set format flags (public member function)
- ios_base::setf
- Set specific format flags (public member function)
- ios_base::unsetf
- Clear specific format flags (public member function)
- setiosflags
- Set format flags (function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us