久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <i id='oM0FB'><tr id='oM0FB'><dt id='oM0FB'><q id='oM0FB'><span id='oM0FB'><b id='oM0FB'><form id='oM0FB'><ins id='oM0FB'></ins><ul id='oM0FB'></ul><sub id='oM0FB'></sub></form><legend id='oM0FB'></legend><bdo id='oM0FB'><pre id='oM0FB'><center id='oM0FB'></center></pre></bdo></b><th id='oM0FB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oM0FB'><tfoot id='oM0FB'></tfoot><dl id='oM0FB'><fieldset id='oM0FB'></fieldset></dl></div>
        <bdo id='oM0FB'></bdo><ul id='oM0FB'></ul>

      1. <legend id='oM0FB'><style id='oM0FB'><dir id='oM0FB'><q id='oM0FB'></q></dir></style></legend>
        <tfoot id='oM0FB'></tfoot>

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

        C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別

        Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)

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

          <bdo id='AJAca'></bdo><ul id='AJAca'></ul>

            <tfoot id='AJAca'></tfoot>

                  <tbody id='AJAca'></tbody>
                <legend id='AJAca'><style id='AJAca'><dir id='AJAca'><q id='AJAca'></q></dir></style></legend>

                • <i id='AJAca'><tr id='AJAca'><dt id='AJAca'><q id='AJAca'><span id='AJAca'><b id='AJAca'><form id='AJAca'><ins id='AJAca'></ins><ul id='AJAca'></ul><sub id='AJAca'></sub></form><legend id='AJAca'></legend><bdo id='AJAca'><pre id='AJAca'><center id='AJAca'></center></pre></bdo></b><th id='AJAca'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AJAca'><tfoot id='AJAca'></tfoot><dl id='AJAca'><fieldset id='AJAca'></fieldset></dl></div>
                • 本文介紹了C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  throw()noexcept 除了分別在運(yùn)行時(shí)和編譯時(shí)檢查之外,還有什么區(qū)別嗎?

                  Is there any difference between throw() and noexcept other than being checked at runtime and compile time, respectively?

                  這篇維基百科 C++11 文章表明 C++03 拋出說明符已棄用.
                  為什么是這樣,noexcept 是否足以在編譯時(shí)涵蓋所有這些內(nèi)容?

                  This Wikipedia C++11 article suggests that the C++03 throw specifiers are deprecated.
                  Why so, is noexcept capable enough to cover all that at compile time ?

                  [注意:我檢查了這個(gè)問題和這篇文章,但無法確定棄用的確切原因.]

                  [Note: I checked this question and this article, but couldn't determine the solid reason for deprecation.]

                  推薦答案

                  異常說明符已被棄用,因?yàn)楫惓Uf明符通常是一個(gè)糟糕的主意.添加 noexcept 是因?yàn)樗钱惓Uf明符的一個(gè)相當(dāng)有用的用法:知道函數(shù)何時(shí)不會拋出異常.因此它變成了一個(gè)二元選擇:會拋出的函數(shù)和不會拋出的函數(shù).

                  Exception specifiers were deprecated because exception specifiers are generally a terrible idea. noexcept was added because it's the one reasonably useful use of an exception specifier: knowing when a function won't throw an exception. Thus it becomes a binary choice: functions that will throw and functions that won't throw.

                  noexcept 而不是刪除除 throw() 之外的所有 throw 說明符,因?yàn)?noexcept 更強(qiáng)大.noexcept 可以有一個(gè)編譯時(shí)解析為布爾值的參數(shù).如果布爾值為真,則 noexcept 堅(jiān)持.如果布爾值為 false,則 noexcept 不會粘住,函數(shù)可能會拋出.

                  noexcept was added rather than just removing all throw specifiers other than throw() because noexcept is more powerful. noexcept can have a parameter which compile-time resolves into a boolean. If the boolean is true, then the noexcept sticks. If the boolean is false, then the noexcept doesn't stick and the function may throw.

                  因此,您可以執(zhí)行以下操作:

                  Thus, you can do something like this:

                  struct<typename T>
                  {
                    void CreateOtherClass() { T t{}; }
                  };
                  

                  CreateOtherClass 會拋出異常嗎?它可能,如果 T 的默認(rèn)構(gòu)造函數(shù)可以.我們怎么講?像這樣:

                  Does CreateOtherClass throw exceptions? It might, if T's default constructor can. How do we tell? Like this:

                  struct<typename T>
                  {
                    void CreateOtherClass() noexcept(is_nothrow_default_constructible<T>::value) { T t{}; }
                  };
                  

                  因此,如果給定類型的默認(rèn)構(gòu)造函數(shù)拋出,CreateOtherClass() 將拋出.這解決了異常說明符的主要問題之一:它們無法向上傳播調(diào)用堆棧.

                  Thus, CreateOtherClass() will throw iff the given type's default constructor throws. This fixes one of the major problems with exception specifiers: their inability to propagate up the call stack.

                  你不能用 throw() 做到這一點(diǎn).

                  You can't do this with throw().

                  這篇關(guān)于C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時(shí),C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時(shí)以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                  Should the exception thrown by boost::asio::io_service::run() be caught?(應(yīng)該捕獲 boost::asio::io_service::run() 拋出的異常嗎?)

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

                            <tfoot id='r35SQ'></tfoot>

                            <legend id='r35SQ'><style id='r35SQ'><dir id='r35SQ'><q id='r35SQ'></q></dir></style></legend>

                            主站蜘蛛池模板: 国产精品视频一区二区三区 | 午夜成人在线视频 | 日韩视频一区二区三区 | 欧美一区二区三区免费 | 欧美日韩一区二区在线 | 成人国产精品视频 | 国产aⅴ爽av久久久久成人 | 亚洲国产成人精品女人 | 毛片网站在线观看 | 六月婷婷在线 | 波多野结衣乳巨码无在线观看 | av一级在线 | 天天干天天操天天射 | 麻豆精品久久 | 闷骚老干部cao个爽 欧美区一区二 | 亚洲 欧美 另类 综合 偷拍 | 视频一区中文字幕 | 五月婷婷 | 亚洲va韩国va欧美va精品 | 特级黄色大片 | 性久久久久久 | 亚洲国产三级 | 91亚洲一区| 丁香在线视频 | 在线视频日本 | 美国一级大黄一片免费中文 | 日本在线一区二区三区 | 欧美色综合网 | av在线免费网站 | 破处视频在线观看 | 少妇bbw搡bbbb搡bbbb | 欧美国产在线观看 | www.毛片.com | 日韩国产中文字幕 | 久久久久女人精品毛片九一 | 三级黄色录像片 | 久久瑟瑟 | 国产精品第二页 | 国产免费网址 | 午夜在线观看视频 | 免费成人在线观看 |