Namespaces
Variants

std::ios_base:: fmtflags

From cppreference.net
typedef /*implementation defined*/ fmtflags ;
static constexpr fmtflags dec = /*implementation defined*/

static constexpr fmtflags oct = /*implementation defined*/
static constexpr fmtflags hex = /*implementation defined*/

static constexpr fmtflags basefield = dec | oct | hex ;
static constexpr fmtflags left = /*implementation defined*/

static constexpr fmtflags right = /*implementation defined*/
static constexpr fmtflags internal = /*implementation defined*/

static constexpr fmtflags adjustfield = left | right | internal ;
static constexpr fmtflags scientific = /*implementation defined*/

static constexpr fmtflags fixed = /*implementation defined*/

static constexpr fmtflags floatfield = scientific | fixed ;
static constexpr fmtflags boolalpha = /*implementation defined*/

static constexpr fmtflags showbase = /*implementation defined*/
static constexpr fmtflags showpoint = /*implementation defined*/
static constexpr fmtflags showpos = /*implementation defined*/
static constexpr fmtflags skipws = /*implementation defined*/
static constexpr fmtflags unitbuf = /*implementation defined*/

static constexpr fmtflags uppercase = /*implementation defined*/
**번역 참고사항:** - 모든 C++ 키워드와 식별자(typedef, static, constexpr, fmtflags, dec, oct, hex, basefield, left, right, internal, adjustfield, scientific, fixed, floatfield, boolalpha, showbase, showpoint, showpos, skipws, unitbuf, uppercase)는 원본 그대로 유지 - HTML 태그와 속성은 번역하지 않음 - 태그 내부 텍스트는 번역하지 않음 (본 문서에서는 태그가 명시적으로 없으나 C++ 코드 영역은 동일하게 처리) - /*implementation defined*/ 주석은 번역하지 않음 - 형식 지정자 관련 전문 용어는 영어 원문 유지

사용 가능한 서식 플래그를 지정합니다. 이것은 BitmaskType 입니다. 다음 상수들이 정의되어 있습니다:

상수 설명
dec 정수 입출력에 10진법 사용: 참조 std::dec
oct 정수 입출력에 8진법 사용: 참조 std::oct
hex 정수 입출력에 16진법 사용: 참조 std::hex
basefield dec | oct | hex . 마스킹 연산에 유용함
left 왼쪽 정렬 (오른쪽에 채움 문자 추가): 참조 std::left
right 오른쪽 정렬 (왼쪽에 채움 문자 추가): 참조 std::right
internal 내부 정렬 (내부 지정 지점에 채움 문자 추가): 참조 std::internal
adjustfield left | right | internal . 마스킹 연산에 유용함
scientific 부동 소수점 타입을 과학적 표기법으로 생성하거나, fixed 와 결합 시 16진법 표기 사용: 참조 std::scientific
fixed 부동 소수점 타입을 고정 소수점 표기법으로 생성하거나, scientific 와 결합 시 16진법 표기 사용: 참조 std::fixed
floatfield scientific | fixed . 마스킹 연산에 유용함
boolalpha bool 타입을 영숫자 형식으로 삽입 및 추출: 참조 std::boolalpha
showbase 정수 출력 시 숫자 체계를 나타내는 접두사 생성, 통화 입출력에서 통화 표시자 요구: 참조 std::showbase
showpoint 부동 소수점 숫자 출력 시 무조건 소수점 문자 생성: 참조 std::showpoint
showpos 음수가 아닌 숫자 출력 시 + 문자 생성: 참조 std::showpos
skipws 특정 입력 연산 전 선행 공백 문자 건너뜀: 참조 std::skipws
unitbuf 각 출력 연산 후 출력 버퍼 플러시: 참조 std::unitbuf
uppercase 특정 출력 연산에서 일부 소문자를 대문자로 대체: 참조 std::uppercase

예제

다음 예제는 동일한 결과를 출력하는 여러 가지 다른 방법을 보여줍니다.

#include <iostream>
int main()
{
    const int num = 150;
    // using fmtflags as class member constants:
    std::cout.setf(std::ios_base::hex, std::ios_base::basefield);
    std::cout.setf(std::ios_base::showbase);
    std::cout << num << '\n';
    // using fmtflags as inherited class member constants:
    std::cout.setf (std::ios::hex, std::ios::basefield);
    std::cout.setf (std::ios::showbase);
    std::cout << num << '\n';
    // using fmtflags as object member constants:
    std::cout.setf(std::cout.hex, std::cout.basefield);
    std::cout.setf(std::cout.showbase);
    std::cout << num << '\n';
    // using fmtflags as a type:
    std::ios_base::fmtflags ff;
    ff = std::cout.flags();
    ff &= ~std::cout.basefield;   // unset basefield bits
    ff |= std::cout.hex;          // set hex
    ff |= std::cout.showbase;     // set showbase
    std::cout.flags(ff);
    std::cout << num << '\n';
    // not using fmtflags, but using manipulators:
    std::cout << std::hex << std::showbase << num << '\n';
}

출력:

0x96
0x96
0x96
0x96
0x96

참고 항목

형식 플래그 관리
(public member function)
특정 형식 플래그 설정
(public member function)
특정 형식 플래그 해제
(public member function)
정수 I/O에 사용되는 진법 변경
(function)
채움 문자 변경
(function template)
부동 소수점 I/O에 사용되는 형식 변경
(function)
숫자 진법을 나타내는 접두사 사용 여부 제어
(function)
불리언의 텍스트와 숫자 표현 간 전환
(function)
음수가 아닌 숫자와 함께 + 기호 사용 여부 제어
(function)
부동 소수점 표현에서 항상 소수점 포함 여부 제어
(function)
각 연산 후 출력 플러시 여부 제어
(function)
입력 시 선행 공백 건너뛰기 여부 제어
(function)
일부 출력 형식에서 대문자 사용 여부 제어
(function)