C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- è¾å ¥/è¾åºæçºµç¬¦
- std::showpoint, std::noshowpoint
- std::setprecision
- std::fixed, std::scientific, std::hexfloat, std::defaultfloat
- std::setbase
- std::showbase, std::noshowbase
- std::quoted
- std::boolalpha, std::noboolalpha
- std::dec, std::hex, std::oct
- std::setfill
- std::setw
- std::left, std::right, std::internal
- std::showpos, std::noshowpos
- std::uppercase, std::nouppercase
- std::ws
- std::ends
- std::skipws, std::noskipws
- std::flush
- std::endl
- std::flush_emit
- std::unitbuf, std::nounitbuf
- std::emit_on_flush, std::no_emit_on_flush
- std::resetiosflags
- std::setiosflags
- std::get_money
- std::get_time
- std::put_money
- std::put_time
- C 飿 ¼æä»¶è¾å ¥/è¾åº
- std::basic_streambuf
- std::basic_filebuf
- std::basic_stringbuf
- std::strstreambuf
- std::basic_syncbuf
- std::basic_ios
- std::basic_istream
- std::ios_base
- std::basic_osyncstream
- std::basic_ostream
- std::basic_iostream
- std::basic_ifstream
- std::basic_ofstream
- std::basic_fstream
- std::basic_istringstream
- std::basic_ostringstream
- std::basic_stringstream
- std::istrstream
- std::ostrstream
- std::strstream
- std::streamoff
- std::streamsize
- std::fpos
- std::iostream_category
- std::io_errc
- std::cin, std::wcin
- std::cout, std::wcout
- std::cerr, std::wcerr
- std::clog, std::wclog
- 注é
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >è¾å ¥/è¾åºåº >è¾å ¥/è¾åºæçºµç¬¦ > std::boolalpha, std::noboolalpha
std::boolalpha, std::noboolalpha
| å®ä¹äºå¤´æä»¶ <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 <sstream> #include <locale> #include <iostream> int main() { // boolalpha è¾åº std::cout << std::boolalpha << "boolalpha true: " << true << '\n' << "boolalpha false: " << false << '\n'; std::cout << 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 " << b1 << ' ' << b2 << '\n'; }
è¾åºï¼
boolalpha true: true boolalpha false: false noboolalpha true: 1 noboolalpha false: 0 "true false" parsed as 1 0
åé
| æ¸
餿å®ç ios_base æ å¿ (彿°) | |
| 设置æå®ç ios_base æ å¿ (彿°) | |
| æä¾ç¨ä½å¸å° true å false åç§°çå符串 ( std::numpunct<CharT> çèåä¿æ¤æå彿°) |