CACAO
Macros
assert.hpp File Reference

Additional assertion macros. More...

Go to the source code of this file.

Macros

#define STATIC_ASSERT(EXPR, MSG)   static_assert(EXPR, MSG);
 An assertion that is evaluated at compile time. More...
 
#define EXPENSIVE_ASSERT(EXPR)   assert(EXPR)
 An assertion that performs computations too expensive even for a normal debug build. More...
 

Detailed Description

Additional assertion macros.

Definition in file assert.hpp.

Macro Definition Documentation

#define EXPENSIVE_ASSERT (   EXPR)    assert(EXPR)

An assertion that performs computations too expensive even for a normal debug build.

EXPENSIVE_ASSERT is even disabled in a normal debug build. You can enable these assertions explicitly by configuring CACAO with: –enable-expensive-assert

Definition at line 90 of file assert.hpp.

#define STATIC_ASSERT (   EXPR,
  MSG 
)    static_assert(EXPR, MSG);

An assertion that is evaluated at compile time.

The evaluated expression must be a compile time constant.

If possible this uses the C++11 static_assert feature, otherwise it uses a fallback that produces substantially worse error messages.

A static assert can appear anywhere a typedef can, that is, in global, class or function scope. In order to support disabling static assertions STATIC_ASSERT does not require a trailing ';'

An example:

* STATIC_ASSERT(1 + 1 == 2, "Math is hard") // compiles without error
* STATIC_ASSERT(5 > 6, "Math is hard") // causes a compilation error
*
Remarks
The fallback version cannot handle multiple STATIC_ASSERTs on one line.

Definition at line 59 of file assert.hpp.