久久久久久久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 之間的區別

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

        <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 之間的區別的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  throw()noexcept 除了分別在運行時和編譯時檢查之外,還有什么區別嗎?

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

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

                  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 ?

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

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

                  推薦答案

                  異常說明符已被棄用,因為異常說明符通常是一個糟糕的主意.添加 noexcept 是因為它是異常說明符的一個相當有用的用法:知道函數何時不會拋出異常.因此它變成了一個二元選擇:會拋出的函數和不會拋出的函數.

                  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 說明符,因為 noexcept 更強大.noexcept 可以有一個編譯時解析為布爾值的參數.如果布爾值為真,則 noexcept 堅持.如果布爾值為 false,則 noexcept 不會粘住,函數可能會拋出.

                  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.

                  因此,您可以執行以下操作:

                  Thus, you can do something like this:

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

                  CreateOtherClass 會拋出異常嗎?它可能,如果 T 的默認構造函數可以.我們怎么講?像這樣:

                  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{}; }
                  };
                  

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

                  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() 做到這一點.

                  You can't do this with throw().

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

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

                  相關文檔推薦

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

                            主站蜘蛛池模板: 日韩中文字幕一区二区 | 国产欧美精品一区二区 | 日韩欧美不卡 | 国产在线网址 | 91视频在线观看 | 欧美日韩中文字幕 | 女人av | 欧美性生活一区二区三区 | 日本一区二区高清视频 | 一区二区三区在线观看视频 | 欧美久久久久久 | 婷婷五月色综合香五月 | 亚洲a在线观看 | 成人不卡视频 | 精品免费国产视频 | 久久久久国色av免费观看性色 | 欧美一区二区三区在线看 | 男女羞羞视频在线观看 | 91精品国产欧美一区二区成人 | 久久国产精品偷 | 国产精品久久片 | 在线亚洲精品 | 国产黄色av网站 | 久久精品中文字幕 | 久久久精彩视频 | 中文字幕av一区 | 中文字幕视频在线 | 色资源在线视频 | 国产精品视频999 | 午夜精品 | 精品国产黄a∨片高清在线 成人区精品一区二区婷婷 日本一区二区视频 | 先锋资源吧 | 91视频三区 | 碰碰视频 | 欧美日韩成人在线 | 成人免费视频在线观看 | 欧美一级三级 | 欧美在线一区二区三区 | 日韩中文欧美 | 日韩在线观看一区二区三区 | 二区在线视频 |