std:: showbase, std:: noshowbase
|
헤더 파일에 정의됨
<ios>
|
||
|
std::
ios_base
&
showbase
(
std::
ios_base
&
str
)
;
|
(1) | |
|
std::
ios_base
&
noshowbase
(
std::
ios_base
&
str
)
;
|
(2) | |
이것은 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
플래그를 설정함
(함수) |