此外,静态断言不生成任何代码。
Boost静态断言的行为。
下面是一些典型的现实情景,您应该在其中考虑使用静态断言。
Here are some typical real-world situations in which you should consider using a static assertion.
可以在全局范围以及在名称空间、函数体或类声明内使用静态断言。
You can use static assertions in global scope and inside namespaces, function bodies, or class declarations.
静态断言建立在这个基本概念之上,只不过静态断言仅在编译时有效。
Static assertions build on this basic concept, except that static assertions are valid only at compile time.
一定要记住,在使用静态断言时,检查的表达式在编译时必须是可计算的。
While using static assertions, always remember that the expression being checked must be evaluable at compile time.
您可以在类、函数或命名空间范围中使用Boost静态断言;还可以与模板一起使用它们。
You can use Boost static assertions in a class, function, or namespace scope; you can also use them with templates.
通常静态断言在类或模板函数中使用时,模板实例后,静态断言才能在实例的模板中实例。
Normally static assertions when used inside a class or function template, will not be instantiated until the template in which it is used is instantiated.
实验表明,提出的全自动静态断言验证方法不仅可行,而且验证代价较小,具有较强的实用性。
It's shown by the experiments that the assertion verification method presented in this paper not only is feasible but also has little verification cost.
一般,得到工作于名字空间、函数、类作用域的优秀的静态断言要比多使用一个难看的宏要值得。
The general conclusion was that the good of a static assert working at namespace, function, and class scope outweighed the ugliness of a macro.
其中一些特性(比如静态断言)是在GCC 4.3 中首次出现的,而lambda函数是在 GCC 4.5 中首次出现的。
Some of these features—like static assertions—first made their appearance in GCC version 4.3, while lambda functions first appeared with the 4.5 release.
假定与运行时断言相似,不同之处在于静态检验的方式。
Assumptions are similar to assertions at runtime, but differ during static verification.
假定与运行时断言相似,不同之处在于静态检验的方式。
Assumptions are similar to assertions at runtime, but differ during static verification.
应用推荐