<tfoot id='pr0NL'></tfoot>

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

    • <bdo id='pr0NL'></bdo><ul id='pr0NL'></ul>
  • <legend id='pr0NL'><style id='pr0NL'><dir id='pr0NL'><q id='pr0NL'></q></dir></style></legend>
    <i id='pr0NL'><tr id='pr0NL'><dt id='pr0NL'><q id='pr0NL'><span id='pr0NL'><b id='pr0NL'><form id='pr0NL'><ins id='pr0NL'></ins><ul id='pr0NL'></ul><sub id='pr0NL'></sub></form><legend id='pr0NL'></legend><bdo id='pr0NL'><pre id='pr0NL'><center id='pr0NL'></center></pre></bdo></b><th id='pr0NL'></th></span></q></dt></tr></i><div id='pr0NL'><tfoot id='pr0NL'></tfoot><dl id='pr0NL'><fieldset id='pr0NL'></fieldset></dl></div>

      1. BOOST_STATIC_ASSERT 没有提升

        BOOST_STATIC_ASSERT without boost(BOOST_STATIC_ASSERT 没有提升)
        <i id='CpOkG'><tr id='CpOkG'><dt id='CpOkG'><q id='CpOkG'><span id='CpOkG'><b id='CpOkG'><form id='CpOkG'><ins id='CpOkG'></ins><ul id='CpOkG'></ul><sub id='CpOkG'></sub></form><legend id='CpOkG'></legend><bdo id='CpOkG'><pre id='CpOkG'><center id='CpOkG'></center></pre></bdo></b><th id='CpOkG'></th></span></q></dt></tr></i><div id='CpOkG'><tfoot id='CpOkG'></tfoot><dl id='CpOkG'><fieldset id='CpOkG'></fieldset></dl></div>
          <tbody id='CpOkG'></tbody>

      2. <legend id='CpOkG'><style id='CpOkG'><dir id='CpOkG'><q id='CpOkG'></q></dir></style></legend>
          • <tfoot id='CpOkG'></tfoot>
              <bdo id='CpOkG'></bdo><ul id='CpOkG'></ul>

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

                  本文介绍了BOOST_STATIC_ASSERT 没有提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  由于我工作的公司禁止使用 boost,因此我需要用纯 C++ 实现其功能.我已经研究了 boost 源,但它们似乎太复杂而无法理解,至少对我来说是这样.我知道 C++0x 标准中有一种叫做 static_assert() 的东西,但我不想使用任何 C++0x 特性.

                  Since boost is forbidden in a company I work for I need to implement its functionality in pure C++. I've looked into boost sources but they seem to be too complex to understand, at least for me. I know there is something called static_assert() in the C++0x standart, but I'd like not to use any C++0x features.

                  推荐答案

                  另一个技巧(可以在 C 中使用)是在断言失败时尝试构建一个大小为负的数组:

                  One other trick (which can be used in C) is to try to build an array with a negative size if the assert fail:

                  #define ASSERT(cond) int foo[(cond) ? 1 : -1]
                  

                  作为奖励,您可以使用 typedef 而不是对象,这样它就可以在更多上下文中使用并且在成功时不会发生:

                  as a bonus, you may use a typedef instead of an object, so that it is usable in more contexts and doesn't takes place when it succeed:

                  #define ASSERT(cond) typedef int foo[(cond) ? 1 : -1]
                  

                  最后,构建一个名称冲突可能性较小的名称(并且至少可以在不同的行中重复使用):

                  finally, build a name with less chance of name clash (and reusable at least in different lines):

                  #define CAT_(a, b) a ## b
                  #define CAT(a, b) CAT_(a, b)
                  #define ASSERT(cond) typedef int CAT(AsSeRt, __LINE__)[(cond) ? 1 : -1]
                  

                  这篇关于BOOST_STATIC_ASSERT 没有提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)
                    <tbody id='mLBl4'></tbody>

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

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

                          1. <small id='mLBl4'></small><noframes id='mLBl4'>

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