<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 靜態(編譯期)斷言 — static_assert 靜態(編譯期)斷言由一個常量表達式及一個字符串文本構成: ``` static_assert(expression, string); ``` **expression**在編譯期進行求值,當結果為false(即:斷言失敗)時,將**string**作為錯誤消息輸出。例如: ``` static_assert(sizeof(long) >= 8, “64-bit code generation required for this library.”); struct S { X m1; Y m2; }; static_assert(sizeof(S)==sizeof(X)+sizeof(Y), ”unexpected padding in S”); ``` static_assert在判斷代碼的編譯環境方面(譯注:比如判斷當前編譯環境是否64位)十分有用。但需要注意的是,由于static_assert在編譯期進行求值,它不能對那些依賴于運行期計算的值的進行檢驗。例如: ``` int f(int* p, int n) { //錯誤:表達式“p == 0”不是一個常量表達式 static_assert(p == 0, “p is not null”); } ``` (正確的做法是在運行期進行判斷,假如條件不成立則拋出異常) 參考: * the C++ draft 7 [4]. * [N1381==02-0039] Robert Klarer and John Maddock: [Proposal to Add Static Assertions to the Core Language](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1381.htm) . * [N1720==04-0160] Robert Klarer, John Maddock, Beman Dawes, Howard Hinnant: [Proposal to Add Static Assertions to the Core Language (Revision 3)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html) . (翻譯:張瀟,dabaitu)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看