BDE 4.14.0 Production release
|
Classes | |
struct | BSLMF_COMPILE_TIME_ASSERTION_FAILURE< IS_VALID > |
struct | BSLMF_COMPILE_TIME_ASSERTION_FAILURE< true > |
Macros | |
#define | BSLMF_ASSERT_CAT(X, Y) BSLMF_ASSERT_CAT_IMP1(X, Y) |
#define | BSLMF_ASSERT_CAT_IMP1(X, Y) BSLMF_ASSERT_CAT_IMP2(X, Y) |
#define | BSLMF_ASSERT_CAT_IMP2(X, Y) X##Y |
#define | BSLMF_ASSERT(expr) |
Provide a compile-time assertion facility.
This component defines a macro that will generate a compile-time error if its constant integral expression argument evaluates to false (i.e., a value of 0
). The BSLMF_ASSERT
macro is similar to the standard run-time assert
macro, except that its argument is evaluated at compile-time, it produces no executable code, and it can be used safely in header files.
The second line will result in a compile error with a message stating that the type BSLMF_COMPILE_TIME_ASSERTION_FAILURE
is incomplete, usually preceded by the file and line number where the macro was used. The following error message is typical of most compilers:
If the macro argument is true, the macro will generate an innocuous typedef
with a name that is the concatenation of the symbol bslmf::Assert
, and the value of __LINE__
(which will be the line number in the file where the macro was called). For example, the first line from the example above might result in the following statement:
Note that these generated typedefs are implementation details of the compile-time checking facility and are not intended to be used directly outside of this component.
Attempting to invoke BSLMF_ASSERT
on a non-compile-time value will typically result in a compilation error.
BSLMF_ASSERT
can be used at namespace, class, and function scope to assert compile-time conditions. !WARNING:! a compiler bug on certain platforms produces an error when the BSLMF_ASSERT
macro is used more than once on the same line in class scope.
#define BSLMF_ASSERT | ( | expr | ) |
#define BSLMF_ASSERT_CAT | ( | X, | |
Y | |||
) | BSLMF_ASSERT_CAT_IMP1(X, Y) |
#define BSLMF_ASSERT_CAT_IMP1 | ( | X, | |
Y | |||
) | BSLMF_ASSERT_CAT_IMP2(X, Y) |
#define BSLMF_ASSERT_CAT_IMP2 | ( | X, | |
Y | |||
) | X##Y |