Namespaces
Variants

std:: boolalpha, std:: noboolalpha

From cppreference.net
< cpp ‎ | io ‎ | manip
Input/output manipulators
Floating-point formatting
Integer formatting
Boolean formatting
boolalpha noboolalpha
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 & boolalpha ( std:: ios_base & str ) ;
(1)
std:: ios_base & noboolalpha ( std:: ios_base & str ) ;
(2)
1) 스트림 str 에서 boolalpha 플래그를 활성화합니다. 마치 str. setf ( std:: ios_base :: boolalpha ) 를 호출한 것처럼 동작합니다.
2) 스트림 str 에서 boolalpha 플래그를 비활성화합니다. 마치 str. unsetf ( std:: ios_base :: boolalpha ) 를 호출하는 것처럼 동작합니다.

std::boolalpha 는 I/O 조작자이므로, out << std :: boolalpha 와 같은 표현식으로 std::basic_ostream 타입의 모든 out 에 대해 호출될 수 있으며, in >> std :: boolalpha 와 같은 표현식으로 std::basic_istream 타입의 모든 in 에 대해 호출될 수 있습니다.

목차

매개변수

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

반환값

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

예제

#include <iostream>
#include <sstream>
int main()
{
    // boolalpha 출력
    std::cout << "default true: " << true << '\n'
              << "default false: " << false << '\n'
              << std::boolalpha 
              << "boolalpha true: " << true << '\n'
              << "boolalpha false: " << false << '\n'
              << std::noboolalpha 
              << "noboolalpha true: " << true << '\n'
              << "noboolalpha false: " << false << '\n';
    // boolalpha 파싱
    bool b1, b2;
    std::istringstream is("true false");
    is >> std::boolalpha >> b1 >> b2;
    std::cout << '"' << is.str() << "\" parsed as: "
              << std::boolalpha << b1 << ' ' << b2 << '\n';
}

출력:

default true: 1
default false: 0
boolalpha true: true
boolalpha false: false
noboolalpha true: 1
noboolalpha false: 0
"true false" parsed as: true false

참고 항목

지정된 ios_base 플래그를 지움
(함수)
지정된 ios_base 플래그를 설정함
(함수)
boolean 값 true false 의 이름으로 사용할 문자열을 제공함
( std::numpunct<CharT> 의 가상 protected 멤버 함수)