SPH
Classes | Macros | Functions
Assert.h File Reference

Custom assertions. More...

#include "common/Globals.h"
#include <exception>
#include <sstream>

Go to the source code of this file.

Classes

struct  Assert
 
class  Assert::Exception
 
struct  Assert::ScopedAssertExceptionEnabler
 

Macros

#define TODO(x)   Assert::todo(x, __FUNCTION__, __LINE__);
 
#define SPH_ASSERT(x, ...)   MARK_USED(x)
 
#define CONSTEXPR_SPH_ASSERT(x)   MARK_USED(x)
 
#define SPH_ASSERT_UNEVAL(x, ...)
 
#define NOT_IMPLEMENTED
 Helper macro marking missing implementation. More...
 
#define STOP
 
#define SPH_STR(x)   SPH_XSTR(x)
 
#define SPH_XSTR(x)   #x
 

Functions

template<typename TDerived , typename TBase >
INLINE TDerived assert_cast (TBase *value)
 

Detailed Description

Custom assertions.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file Assert.h.

Macro Definition Documentation

◆ CONSTEXPR_SPH_ASSERT

#define CONSTEXPR_SPH_ASSERT (   x)    MARK_USED(x)

Definition at line 95 of file Assert.h.

◆ NOT_IMPLEMENTED

#define NOT_IMPLEMENTED
Value:
SPH_ASSERT(false, "not implemented"); \
throw Assert::Exception(std::string("Functionality not implemented in function ") + __PRETTY_FUNCTION__);
#define SPH_ASSERT(x,...)
Definition: Assert.h:94

Helper macro marking missing implementation.

Definition at line 100 of file Assert.h.

◆ SPH_ASSERT

#define SPH_ASSERT (   x,
  ... 
)    MARK_USED(x)

Definition at line 94 of file Assert.h.

◆ SPH_ASSERT_UNEVAL

#define SPH_ASSERT_UNEVAL (   x,
  ... 
)

Definition at line 96 of file Assert.h.

◆ SPH_STR

#define SPH_STR (   x)    SPH_XSTR(x)

Definition at line 119 of file Assert.h.

◆ SPH_XSTR

#define SPH_XSTR (   x)    #x

Definition at line 120 of file Assert.h.

◆ STOP

#define STOP
Value:
SPH_ASSERT(false, "stop"); \
throw std::exception();

Helper macro marking code that should never be executed (default branch of switch where there is finite number of options, for example)

Definition at line 106 of file Assert.h.

◆ TODO

#define TODO (   x)    Assert::todo(x, __FUNCTION__, __LINE__);

Definition at line 84 of file Assert.h.

Function Documentation

◆ assert_cast()

template<typename TDerived , typename TBase >
INLINE TDerived assert_cast ( TBase *  value)

Helper cast, performing a static_cast, but checking that the cast is valid using dynamic_cast in assert and debug builds.

Definition at line 113 of file Assert.h.