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

<tfoot id='VU4zF'></tfoot>
    1. <small id='VU4zF'></small><noframes id='VU4zF'>

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

        • <bdo id='VU4zF'></bdo><ul id='VU4zF'></ul>
        <legend id='VU4zF'><style id='VU4zF'><dir id='VU4zF'><q id='VU4zF'></q></dir></style></legend>

      1. 變量上的 const 與 constexpr

        const vs constexpr on variables(變量上的 const 與 constexpr)

      2. <tfoot id='UJ2YF'></tfoot>
          <legend id='UJ2YF'><style id='UJ2YF'><dir id='UJ2YF'><q id='UJ2YF'></q></dir></style></legend>

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

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

                    <tbody id='UJ2YF'></tbody>
                1. 本文介紹了變量上的 const 與 constexpr的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  以下定義有區(qū)別嗎?

                  const     double PI = 3.141592653589793;
                  constexpr double PI = 3.141592653589793;
                  

                  如果不是,那么在 C++11 中更喜歡哪種風(fēng)格?

                  If not, which style is preferred in C++11?

                  推薦答案

                  我相信是有區(qū)別的.讓我們重命名它們,以便我們可以更輕松地討論它們:

                  I believe there is a difference. Let's rename them so that we can talk about them more easily:

                  const     double PI1 = 3.141592653589793;
                  constexpr double PI2 = 3.141592653589793;
                  

                  PI1PI2 都是常量,意味著你不能修改它們.但是 PI2 是編譯時(shí)常量.它應(yīng)在編譯時(shí)初始化.PI1 可以在編譯時(shí)或運(yùn)行時(shí)初始化.此外, PI2 可以在需要編譯時(shí)常量的上下文中使用.例如:

                  Both PI1 and PI2 are constant, meaning you can not modify them. However only PI2 is a compile-time constant. It shall be initialized at compile time. PI1 may be initialized at compile time or run time. Furthermore, only PI2 can be used in a context that requires a compile-time constant. For example:

                  constexpr double PI3 = PI1;  // error
                  

                  但是:

                  constexpr double PI3 = PI2;  // ok
                  

                  和:

                  static_assert(PI1 == 3.141592653589793, "");  // error
                  

                  但是:

                  static_assert(PI2 == 3.141592653589793, "");  // ok
                  

                  至于您應(yīng)該使用哪個(gè)?使用滿足您需求的任何一種.你想確保你有一個(gè)編譯時(shí)常量可以在需要編譯時(shí)常量的上下文中使用嗎?您是否希望能夠使用在運(yùn)行時(shí)完成的計(jì)算來(lái)初始化它?等

                  As to which you should use? Use whichever meets your needs. Do you want to ensure that you have a compile time constant that can be used in contexts where a compile-time constant is required? Do you want to be able to initialize it with a computation done at run time? Etc.

                  這篇關(guān)于變量上的 const 與 constexpr的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Why do two functions have the same address?(為什么兩個(gè)函數(shù)的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復(fù)制構(gòu)造的?)
                  mixing templates with polymorphism(混合模板與多態(tài)性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時(shí)候應(yīng)該使用關(guān)鍵字“typename?使用模板時(shí))
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標(biāo)準(zhǔn)庫(kù))
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)

                    <tfoot id='Kyap4'></tfoot><legend id='Kyap4'><style id='Kyap4'><dir id='Kyap4'><q id='Kyap4'></q></dir></style></legend>
                      • <bdo id='Kyap4'></bdo><ul id='Kyap4'></ul>

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

                      • <small id='Kyap4'></small><noframes id='Kyap4'>

                          <tbody id='Kyap4'></tbody>

                          1. 主站蜘蛛池模板: 一区二区久久精品 | 一区二区三区四区国产 | 国产黄色一级电影 | 欧美精品久久 | 欧美三区在线观看 | av入口 | 91影片 | 国产乱码高清区二区三区在线 | 中文字字幕一区二区三区四区五区 | 91av视频 | 久久久国产精品入口麻豆 | 午夜看看 | 免费在线看a | 欧美日韩一区二区三区不卡视频 | 欧美在线视频网 | 91视在线国内在线播放酒店 | 天天爱爱网 | 亚洲精品久久久久中文字幕欢迎你 | 免费观看av网站 | 国产精品久久久久免费 | 91精品久久久久久久久中文字幕 | www.国产.com| 国产精品一区二区三区四区 | 久久精品亚洲精品国产欧美 | ww亚洲ww亚在线观看 | 日韩在线视频免费观看 | 午夜精品久久久久久久久久久久 | 91精品国产91综合久久蜜臀 | 国产欧美在线观看 | 九九九视频精品 | 一区网站 | 国产午夜视频 | 精品久久久久国产 | 欧洲一级黄 | 国产小视频在线 | 欧美簧片| 日韩欧美国产一区二区 | 精品久久久久久久久久久 | 国产精品免费一区二区三区四区 | 久久精品久久久 | 久久综合伊人 |