claw  1.9.0
Namespaces | Macros | Functions
assert.hpp File Reference

Some assert macros to strengthen you code. More...

#include <cstdlib>
#include <iostream>
#include <sstream>
Include dependency graph for assert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 claw
 This is the main namespace.
 

Macros

#define CLAW_ASSERT(b, s)   claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, (b), (s))
 Print a message on std::cerr and stop the program if a condition is not true. More...
 
#define CLAW_FAIL(s)   claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, false, (s))
 Print a message on std::cerr and stop the program. More...
 
#define CLAW_PRECOND(b)   CLAW_ASSERT(b, "precondition failed: " #b)
 Abort the program if a precondition is not true. More...
 
#define CLAW_POSTCOND(b)   CLAW_ASSERT(b, "postcondition failed: " #b)
 Abort the program if a postcondition is not true. More...
 

Functions

void claw::debug_assert (const char *file, const char *func, unsigned int line, bool b, const std::string &s)
 The method used by CLAW_ASSERT macro. Souldn't be used elsewhere. More...
 

Detailed Description

Some assert macros to strengthen you code.

Author
Julien Jorge

Definition in file assert.hpp.

Macro Definition Documentation

◆ CLAW_ASSERT

CLAW_ASSERT (   b,
 
)    claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, (b), (s))

Print a message on std::cerr and stop the program if a condition is not true.

Parameters
bCondition to verify.
sAn error message.

Definition at line 88 of file assert.hpp.

◆ CLAW_FAIL

CLAW_FAIL (   s)    claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, false, (s))

Print a message on std::cerr and stop the program.

Parameters
sAn error message.

Definition at line 91 of file assert.hpp.

◆ CLAW_POSTCOND

CLAW_POSTCOND (   b)    CLAW_ASSERT(b, "postcondition failed: " #b)

Abort the program if a postcondition is not true.

Parameters
bCondition to verify.

Definition at line 96 of file assert.hpp.

◆ CLAW_PRECOND

CLAW_PRECOND (   b)    CLAW_ASSERT(b, "precondition failed: " #b)

Abort the program if a precondition is not true.

Parameters
bCondition to verify.

Definition at line 94 of file assert.hpp.