Namespaces
Variants

std:: showbase, std:: noshowbase

From cppreference.net
< cpp ‎ | io ‎ | manip
Input/output manipulators
Floating-point formatting
Integer formatting
showbase noshowbase
Boolean formatting
Field width and fill control
Other formatting
Whitespace processing
Output flushing
Status flags manipulation
Time and money I/O
(C++11)
(C++11)
(C++11)
(C++11)
Quoted manipulator
(C++14)
헤더 파일에 정의됨 <ios>
std:: ios_base & showbase ( std:: ios_base & str ) ;
(1)
std:: ios_base & noshowbase ( std:: ios_base & str ) ;
(2)
1) 스트림 str 에서 showbase 플래그를 활성화합니다. 마치 str. setf ( std:: ios_base :: showbase ) 를 호출한 것처럼 동작합니다.
2) 스트림 str 에서 showbase 플래그를 비활성화합니다. 마치 str. unsetf ( std:: ios_base :: showbase ) 를 호출한 것처럼 동작합니다.

이것은 I/O 조정자이며, out << std :: showbase 와 같은 표현식으로 out std::basic_ostream 타입인 경우 호출될 수 있으며, 또는 in >> std :: showbase 와 같은 표현식으로 in std::basic_istream 타입인 경우 호출될 수 있습니다.

showbase 플래그는 정수 출력(참조: std::num_put::put ), 통화 입력(참조: std::money_get::get ) 및 통화 출력(참조: std::money_put::put )의 동작에 영향을 미칩니다.

목차

매개변수

str - I/O 스트림에 대한 참조

반환값

str (조작 후 스트림에 대한 참조).

참고 사항

std::num_put::put 에 명시된 바와 같이, 정수 출력에서 showbase 플래그는 std::printf 의 # 형식 지정자와 유사하게 동작하며, 이는 값 0을 출력할 때 숫자 진법 접두사가 추가되지 않음 을 의미합니다.

예제

#include <iomanip>
#include <iostream>
#include <locale>
#include <sstream>
int main()
{
    // showbase는 8진수와 16진수 출력에 영향을 줍니다
    std::cout << std::hex
              << "showbase: " << std::showbase << 42 << '\n'
              << "noshowbase: " << std::noshowbase << 42 << '\n';
    // 그리고 통화 값의 입력과 출력 모두에 영향을 줍니다
    std::locale::global(std::locale("en_US.UTF8"));
    long double val = 0;
    std::istringstream("3.14") >> std::showbase >> std::get_money(val);
    std::cout << "With showbase, parsing 3.14 as money gives " << val << '\n';
    std::istringstream("3.14") >> std::noshowbase >> std::get_money(val);
    std::cout << "Without showbase, parsing 3.14 as money gives " << val << '\n';
}

출력:

showbase: 0x2a
noshowbase: 2a
With showbase, parsing 3.14 as money gives 0
Without showbase, parsing 3.14 as money gives 314

참고 항목

지정된 ios_base 플래그를 지움
(함수)
지정된 ios_base 플래그를 설정함
(함수)