KV_ASSERT.h File Reference

Implementation of macro KV_ASSERT. More...

#include "keyvalue/sys/exception/Exception.h"
Include dependency graph for KV_ASSERT.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define KV_ASSERT(cond, msg)
 The assert macro.

Detailed Description

Implementation of macro KV_ASSERT.

Define Documentation

#define KV_ASSERT (   cond,
{                                             \
  if (!(cond))                                                             \
    throw ::keyvalue::LogicError() & __FILE__ & " (" & __LINE__ & ") :\n" &\
      msg;                                                                 \

The assert macro.

This macro is a replacement for the C standard assert macro. Its definition depends on whether the macro NDEBUG is defined or not.

When NDEBUG is not defined, KV_ASSERT checks if a condition holds and, when it does not, it throws a LogicError carrying information on the invalid condition and where it has occurred.

When NDEBUG is defined, KV_ASSERT does not do anything.

cond : Condition to be tested;
msg : Error message to be reported.