pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<small id='tG4gm'></small><noframes id='tG4gm'>

<i id='tG4gm'><tr id='tG4gm'><dt id='tG4gm'><q id='tG4gm'><span id='tG4gm'><b id='tG4gm'><form id='tG4gm'><ins id='tG4gm'></ins><ul id='tG4gm'></ul><sub id='tG4gm'></sub></form><legend id='tG4gm'></legend><bdo id='tG4gm'><pre id='tG4gm'><center id='tG4gm'></center></pre></bdo></b><th id='tG4gm'></th></span></q></dt></tr></i><div class="g00w82y" id='tG4gm'><tfoot id='tG4gm'></tfoot><dl id='tG4gm'><fieldset id='tG4gm'></fieldset></dl></div>
      • <bdo id='tG4gm'></bdo><ul id='tG4gm'></ul>

      <tfoot id='tG4gm'></tfoot>

      <legend id='tG4gm'><style id='tG4gm'><dir id='tG4gm'><q id='tG4gm'></q></dir></style></legend>
      1. basic_ios 上標志的語義

        Semantics of flags on basic_ios(basic_ios 上標志的語義)
          <tbody id='9nSbJ'></tbody>
        • <bdo id='9nSbJ'></bdo><ul id='9nSbJ'></ul>

                • <legend id='9nSbJ'><style id='9nSbJ'><dir id='9nSbJ'><q id='9nSbJ'></q></dir></style></legend>
                  <i id='9nSbJ'><tr id='9nSbJ'><dt id='9nSbJ'><q id='9nSbJ'><span id='9nSbJ'><b id='9nSbJ'><form id='9nSbJ'><ins id='9nSbJ'></ins><ul id='9nSbJ'></ul><sub id='9nSbJ'></sub></form><legend id='9nSbJ'></legend><bdo id='9nSbJ'><pre id='9nSbJ'><center id='9nSbJ'></center></pre></bdo></b><th id='9nSbJ'></th></span></q></dt></tr></i><div class="kumoeug" id='9nSbJ'><tfoot id='9nSbJ'></tfoot><dl id='9nSbJ'><fieldset id='9nSbJ'></fieldset></dl></div>
                • <small id='9nSbJ'></small><noframes id='9nSbJ'>

                  <tfoot id='9nSbJ'></tfoot>
                • 本文介紹了basic_ios 上標志的語義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我發現自己一再被 rdstate() 標志弄糊涂了 - good()bad()eof()fail() - 以及它們在 basic_ios::operator!operator booloperator void 中的表達方式*.

                  I find myself repeatedly baffled by the rdstate() flags - good(), bad(), eof(), fail() - and how they are expressed in basic_ios::operator!, operator bool and operator void*.

                  有人可以讓我擺脫痛苦并解釋這一點,這樣我就不必再三思了嗎?

                  Could somebody put me out of my misery and explain this so I never have to think twice again?

                  推薦答案

                  有三個標志指示錯誤狀態:

                  There are three flags that indicate error state:

                  • badbit 表示流出現了嚴重問題.這可能是緩沖區錯誤或向流中提供數據的任何錯誤.如果設置了此標志,您很可能不會再使用該流.

                  • badbit means something has gone very wrong with the stream. It might be a buffer error or an error in whatever is feeding data to the stream. If this flag is set, it's likely that you aren't going to be using the stream anymore.

                  failbit 意味著從流中提取或讀取失敗(或寫入或插入輸出流),您需要注意該失敗.

                  failbit means that an extraction or a read from the stream failed (or a write or insertion for output streams) and you need to be aware of that failure.

                  eofbit 表示輸入流已經結束,沒有什么可讀取的了.請注意,這僅在您嘗試從已到達其末尾的輸入流中讀取后設置(即,在發生錯誤時設置,因為您嘗試讀取不存在的數據).

                  eofbit means the input stream has reached its end and there is nothing left to read. Note that this is set only after you attempt to read from an input stream that has reached its end (that is, it is set when an error occurs because you try to read data that isn't there).

                  failbit 也可以由許多到達 EOF 的操作設置.例如,如果流中只剩下空白,并且您嘗試讀取 int,那么您將同時到達 EOF 并且無法讀取 int,因此兩個標志都將被設置.

                  The failbit may also be set by many operations that reach EOF. For example, if there is only whitespace left remaining in the stream and you try to read an int, you will both reach EOF and you will fail to read the int, so both flags will be set.

                  fail() 函數測試 badbit ||失敗位.

                  good() 函數測試 !(badbit || failbit || eofbit).也就是說,當沒有設置任何位時,流是好的.

                  The good() function tests !(badbit || failbit || eofbit). That is, a stream is good when none of the bits are set.

                  您可以使用 ios::clear() 成員函數重置標志;這允許您設置任何錯誤標志;默認情況下(不帶參數),它會清除所有三個標志.

                  You can reset the flags by using the ios::clear() member function; this allows you to set any of the error flags; by default (with no argument), it clears all three flags.

                  流不會重載operator bool()operator void*() 用于實現安全布爾習語的一個有點損壞的版本.如果設置了 badbitfailbit,則此運算符重載返回 null,否則返回非 null.您可以使用它來支持測試提取成功作為循環或其他控制流語句的條件的習慣用法:

                  Streams do not overload operator bool(); operator void*() is used to implement a somewhat broken version of the safe bool idiom. This operator overload returns null if badbit or failbit is set, and non-null otherwise. You can use this to support the idiom of testing the success of an extraction as the condition of a loop or other control flow statement:

                  if (std::cin >> x) {
                      // extraction succeeded
                  }
                  else {
                      // extraction failed
                  }
                  

                  operator!() 重載與 operator void*() 相反;如果設置了 badbitfailbit,則返回 true,否則返回 false.operator!() 重載不再需要了;它可以追溯到完全一致地支持運算符重載之前(參見 sbi 的問題 "為什么 std::basic_ios 重載了一元邏輯否定運算符?").

                  The operator!() overload is the opposite of the operator void*(); it returns true if the badbit or failbit is set and false otherwise. The operator!() overload is not really needed anymore; it dates back to before operator overloads were supported completely and consistently (see sbi's question "Why does std::basic_ios overload the unary logical negation operator?").

                  C++0x 修復了導致我們必須使用安全 bool 習慣用法的問題,因此在 C++0x 中,basic_ios 基類模板確實重載了 operator bool() 作為顯式轉換運算符;此運算符與當前的 operator void*() 具有相同的語義.

                  C++0x fixes the problem that causes us to have to use the safe bool idiom, so in C++0x the basic_ios base class template does overload operator bool() as an explicit conversion operator; this operator has the same semantics as the current operator void*().

                  這篇關于basic_ios 上標志的語義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  read input files, fastest way possible?(讀取輸入文件,最快的方法?)
                  The easiest way to read formatted input in C++?(在 C++ 中讀取格式化輸入的最簡單方法?)
                  Reading from .txt file into two dimensional array in c++(從 .txt 文件讀取到 C++ 中的二維數組)
                  How to simulate a key press in C++(如何在 C++ 中模擬按鍵按下)
                  Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(為什么在 cin.ignore() 之后沒有 getline(cin, var) 讀取字符串的第一個字符?)
                  What is the cin analougus of scanf formatted input?(scanf 格式輸入的 cin 類比是什么?)

                      1. <small id='Zw7DJ'></small><noframes id='Zw7DJ'>

                          <tbody id='Zw7DJ'></tbody>
                      2. <legend id='Zw7DJ'><style id='Zw7DJ'><dir id='Zw7DJ'><q id='Zw7DJ'></q></dir></style></legend>

                        <i id='Zw7DJ'><tr id='Zw7DJ'><dt id='Zw7DJ'><q id='Zw7DJ'><span id='Zw7DJ'><b id='Zw7DJ'><form id='Zw7DJ'><ins id='Zw7DJ'></ins><ul id='Zw7DJ'></ul><sub id='Zw7DJ'></sub></form><legend id='Zw7DJ'></legend><bdo id='Zw7DJ'><pre id='Zw7DJ'><center id='Zw7DJ'></center></pre></bdo></b><th id='Zw7DJ'></th></span></q></dt></tr></i><div class="8siyyy0" id='Zw7DJ'><tfoot id='Zw7DJ'></tfoot><dl id='Zw7DJ'><fieldset id='Zw7DJ'></fieldset></dl></div>
                        <tfoot id='Zw7DJ'></tfoot>
                          <bdo id='Zw7DJ'></bdo><ul id='Zw7DJ'></ul>

                            主站蜘蛛池模板: 常州律师事务所_常州律所_常州律师-江苏乐天律师事务所 | 雪花制冰机(实验室雪花制冰机)百科 | 石家庄救护车出租_重症转院_跨省跨境医疗转送_活动赛事医疗保障_康复出院_放弃治疗_腾康26年医疗护送转诊团队 | 美国PARKER齿轮泵,美国PARKER柱塞泵,美国PARKER叶片泵,美国PARKER电磁阀,美国PARKER比例阀-上海维特锐实业发展有限公司二部 | 工业风机_环保空调_冷风机_工厂车间厂房通风降温设备旺成服务平台 | 庭院灯_太阳能景观灯_草坪灯厂家_仿古壁灯-重庆恒投科技 | 空心明胶胶囊|植物胶囊|清真胶囊|浙江绿键胶囊有限公司欢迎您! | 直读光谱仪,光谱分析仪,手持式光谱仪,碳硫分析仪,创想仪器官网 | 电销卡_北京电销卡_包月电话卡-豪付网络 | 精密机械零件加工_CNC加工_精密加工_数控车床加工_精密机械加工_机械零部件加工厂 | 电解抛光加工_不锈钢电解抛光_常州安谱金属制品有限公司 | 免费分销系统 — 分销商城系统_分销小程序开发 -【微商来】 | 气力输送_输送机械_自动化配料系统_负压吸送_制造主力军江苏高达智能装备有限公司! | 转向助力泵/水泵/发电机皮带轮生产厂家-锦州华一精工有限公司 | 软文发布平台 - 云软媒网络软文直编发布营销推广平台 | 洗地机-全自动/手推式洗地机-扫地车厂家_扬子清洁设备 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | 全自动面膜机_面膜折叠机价格_面膜灌装机定制_高速折棉机厂家-深圳市益豪科技有限公司 | 骨灰存放架|骨灰盒寄存架|骨灰架厂家|智慧殡葬|公墓陵园管理系统|网上祭奠|告别厅智能化-厦门慈愿科技 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 超声波反应釜【百科】-以马内利仪器 | 起好名字_取个好名字_好名网免费取好名在线打分 | 西安标准厂房_陕西工业厂房_西咸新区独栋厂房_长信科技产业园官方网站 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 深圳公司注册-工商注册代理-注册公司流程和费用_护航财税 | 螺旋叶片_螺旋叶片成型机_绞龙叶片_莱州源泽机械制造有限公司 | 菲希尔X射线测厚仪-菲希尔库伦法测厚仪-无锡骏展仪器有限责任公司 | 工业机械三维动画制作 环保设备原理三维演示动画 自动化装配产线三维动画制作公司-南京燃动数字 聚合氯化铝_喷雾聚氯化铝_聚合氯化铝铁厂家_郑州亿升化工有限公司 | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 山东限矩型液力偶合器_液力耦合器易熔塞厂家-淄博市汇川源机械厂 | Safety light curtain|Belt Sway Switches|Pull Rope Switch|ultrasonic flaw detector-Shandong Zhuoxin Machinery Co., Ltd | 数控走心机-走心机价格-双主轴走心机-宝宇百科 | 国际线缆连接网 - 连接器_线缆线束加工行业门户网站 | 【化妆品备案】进口化妆品备案流程-深圳美尚美化妆品有限公司 | 上海办公室装修,办公楼装修设计,办公空间设计,企业展厅设计_写艺装饰公司 | 首页|专注深圳注册公司,代理记账报税,注册商标代理,工商变更,企业400电话等企业一站式服务-慧用心 | 浙江美尔凯特智能厨卫股份有限公司| 压力喷雾干燥机,喷雾干燥设备,柱塞隔膜泵-无锡市闻华干燥设备有限公司 | 北京办公室装修,办公室设计,写字楼装修-北京金视觉装饰工程公司 北京成考网-北京成人高考网 | 西装定制/做厂家/公司_西装订做/制价格/费用-北京圣达信西装 |