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

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

    <tfoot id='rkRM9'></tfoot>

      我什么時候應該真正使用 noexcept?

      When should I really use noexcept?(我什么時候應該真正使用 noexcept?)
      1. <small id='s4CW4'></small><noframes id='s4CW4'>

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

                <tfoot id='s4CW4'></tfoot>
                <legend id='s4CW4'><style id='s4CW4'><dir id='s4CW4'><q id='s4CW4'></q></dir></style></legend>
                本文介紹了我什么時候應該真正使用 noexcept?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                noexcept 關鍵字可以適當地應用于許多函數簽名,但我不確定何時應該考慮在實踐中使用它.根據我目前所讀到的內容,最后一分鐘添加的 noexcept 似乎解決了移動構造函數拋出時出現的一些重要問題.但是,對于一些實際問題,我仍然無法提供令人滿意的答案,這些問題使我首先閱讀了有關 noexcept 的更多信息.

                The noexcept keyword can be appropriately applied to many function signatures, but I am unsure as to when I should consider using it in practice. Based on what I have read so far, the last-minute addition of noexcept seems to address some important issues that arise when move constructors throw. However, I am still unable to provide satisfactory answers to some practical questions that led me to read more about noexcept in the first place.

                1. 有很多我知道永遠不會拋出的函數示例,但編譯器無法自行確定.在所有這些情況下,我應該將 noexcept 附加到函數聲明中嗎?

                1. There are many examples of functions that I know will never throw, but for which the compiler cannot determine so on its own. Should I append noexcept to the function declaration in all such cases?

                不得不考慮是否需要在 every 函數聲明之后附加 noexcept 會大大降低程序員的工作效率(坦率地說,會很痛苦).在哪些情況下我應該更小心地使用 noexcept,哪些情況下我可以使用隱含的 noexcept(false)?

                Having to think about whether or not I need to append noexcept after every function declaration would greatly reduce programmer productivity (and frankly, would be a pain in the neck). For which situations should I be more careful about the use of noexcept, and for which situations can I get away with the implied noexcept(false)?

                在使用 noexcept 后,我什么時候才能真正看到性能改進?特別地,給出一個代碼示例,在添加 noexcept 后,C++ 編譯器能夠為其生成更好的機器代碼.

                When can I realistically expect to observe a performance improvement after using noexcept? In particular, give an example of code for which a C++ compiler is able to generate better machine code after the addition of noexcept.

                就我個人而言,我關心 noexcept 因為為編譯器提供了更多的自由來安全地應用某些類型的優化.現代編譯器會以這種方式利用 noexcept 嗎?如果沒有,我可以期待他們中的一些人在不久的將來這樣做嗎?

                Personally, I care about noexcept because of the increased freedom provided to the compiler to safely apply certain kinds of optimizations. Do modern compilers take advantage of noexcept in this way? If not, can I expect some of them to do so in the near future?

                推薦答案

                我認為現在給出最佳實踐"答案還為時過早,因為沒有足夠的時間在實踐中使用它.如果在拋出說明符出現后立即問到這個問題,那么答案將與現在大不相同.

                I think it is too early to give a "best practices" answer for this as there hasn't been enough time to use it in practice. If this was asked about throw specifiers right after they came out then the answers would be very different to now.

                必須考慮是否需要在每個函數聲明后附加 noexcept 會大大降低程序員的工作效率(坦率地說,這會很痛苦).

                Having to think about whether or not I need to append noexcept after every function declaration would greatly reduce programmer productivity (and frankly, would be a pain).

                好吧,那么在很明顯函數永遠不會拋出時使用它.

                Well, then use it when it's obvious that the function will never throw.

                在使用 noexcept 后,我什么時候才能真正看到性能改進?[...] 就我個人而言,我關心 noexcept 因為增加了編譯器的自由度,可以安全地應用某些類型的優化.

                When can I realistically expect to observe a performance improvement after using noexcept? [...] Personally, I care about noexcept because of the increased freedom provided to the compiler to safely apply certain kinds of optimizations.

                似乎最大的優化收益來自用戶優化,而不是編譯器優化,因為可能會檢查 noexcept 并對其進行重載.大多數編譯器遵循無懲罰如果你不拋出異常處理方法,所以我懷疑它會在你的代碼的機器代碼級別上改變很多(或任何東西),盡管可能通過刪除處理代碼.

                It seems like the biggest optimization gains are from user optimizations, not compiler ones due to the possibility of checking noexcept and overloading on it. Most compilers follow a no-penalty-if-you-don't-throw exception handling method, so I doubt it would change much (or anything) on the machine code level of your code, although perhaps reduce the binary size by removing the handling code.

                在四大(構造函數、賦值函數,而不是析構函數,因為它們已經是 noexcept)中使用 noexcept 可能會像 noexcept 那樣帶來最好的改進code> 檢查在模板代碼中是常見的",例如在 std 容器中.例如,std::vector 不會使用你的類的移動,除非它被標記為 noexcept(否則編譯器可以推斷出它).

                Using noexcept in the big four (constructors, assignment, not destructors as they're already noexcept) will likely cause the best improvements as noexcept checks are 'common' in template code such as in std containers. For instance, std::vector won't use your class's move unless it's marked noexcept (or the compiler can deduce it otherwise).

                這篇關于我什么時候應該真正使用 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(從構造函數的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)

                          <tbody id='UhY7q'></tbody>

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

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

                        <tfoot id='UhY7q'></tfoot>
                          <bdo id='UhY7q'></bdo><ul id='UhY7q'></ul>
                        • <legend id='UhY7q'><style id='UhY7q'><dir id='UhY7q'><q id='UhY7q'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 国产精品毛片av | 中文字幕在线视频观看 | www.一区二区 | 中文字幕一二三区 | 一级毛片视频 | 中文字幕欧美一区 | 国产精品久久久久久久久久 | 日韩精品免费一区二区在线观看 | 男女羞羞视频大全 | 国产精品久久久久久久久久东京 | 一区二区三区av | 亚洲一区国产精品 | 999精品视频在线观看 | 久久99国产精品 | 91精品国产91久久久久游泳池 | av在线免费观看网站 | 免费观看一级特黄欧美大片 | 丝袜美腿一区二区三区 | 日韩av在线免费 | av黄色片 | 亚洲精品二区 | 天天草天天操 | 欧美精品在线免费观看 | 亚洲精品视频在线观看视频 | 亚洲国产精品成人无久久精品 | 国产精品久久久久久久粉嫩 | 精品视频999 | 国产7777| 欧美精品在线视频 | 91网站视频在线观看 | 日韩av免费在线观看 | 欧美精品1区2区 | 久久99精品久久久久久国产越南 | 国产在线精品一区二区三区 | 亚洲一区二区三区在线免费 | 国产美女在线精品免费 | 国产成人精品一区二 | 亚洲三区在线 | 成人免费大片黄在线播放 | 欧美在线一区二区三区 | 国产精品99久久久久久久vr |