Template Numerical Library version\ main:4e58ea6
Loading...
Searching...
No Matches
Assert.h File Reference

The purpose of this file is to define the TNL_ASSERT_* debugging macros. More...

#include <string>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <TNL/Backend/Macros.h>
Include dependency graph for Assert.h:

Namespaces

namespace  TNL
 The main TNL namespace.
 
namespace  TNL::Assert
 Internal namespace for helper classes used in the TNL_ASSERT_* macros.
 

Macros

#define __STRING(arg)
 
#define __TNL_ASSERT_PRED2(pred, op, val1, val2, msg)
 
#define __TNL_JOIN_STRINGS(val1, op, val2)
 
#define __TNL_PRETTY_FUNCTION   __PRETTY_FUNCTION__
 
#define TNL_ASSERT_EQ(val1, val2, msg)
 
#define TNL_ASSERT_FALSE(val, msg)
 
#define TNL_ASSERT_GE(val1, val2, msg)
 
#define TNL_ASSERT_GT(val1, val2, msg)
 
#define TNL_ASSERT_LE(val1, val2, msg)
 
#define TNL_ASSERT_LT(val1, val2, msg)
 
#define TNL_ASSERT_NE(val1, val2, msg)
 
#define TNL_ASSERT_TRUE(val, msg)
 
#define TNL_IMPL_CMP_HELPER_(op_name, op)
 

Functions

__cuda_callable__ void TNL::Assert::abortWithDiagnosticsCuda (const char *assertion, const char *message, const char *file, const char *function, int line, const char *diagnostics)
 
void TNL::Assert::abortWithDiagnosticsHost (const char *assertion, const char *message, const char *file, const char *function, int line, const char *diagnostics)
 
template<typename T1 , typename T2 >
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ void TNL::Assert::cmpHelperFalse (const char *assertion, const char *message, const char *file, const char *function, int line, const char *expr1, const char *expr2, const T1 &val1, const T2 &val2)
 
template<typename T1 , typename T2 >
__cuda_callable__ void TNL::Assert::cmpHelperOpFailure (const char *assertion, const char *message, const char *file, const char *function, int line, const char *lhs_expression, const char *rhs_expression, const T1 &lhs_value, const T2 &rhs_value, const char *op)
 
template<typename T1 , typename T2 >
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ void TNL::Assert::cmpHelperTrue (const char *assertion, const char *message, const char *file, const char *function, int line, const char *expr1, const char *expr2, const T1 &val1, const T2 &val2)
 

Detailed Description

The purpose of this file is to define the TNL_ASSERT_* debugging macros.

If the NDEBUG macro is defined, the build is considered to be optimized and all assert macros are empty. Otherwise, the conditions are checked and failures lead to the TNL::Assert::AssertionError exception containing the diagnostics message.

Macro Definition Documentation

◆ __STRING

#define __STRING ( arg)
Value:
#arg

◆ __TNL_ASSERT_PRED2

#define __TNL_ASSERT_PRED2 ( pred,
op,
val1,
val2,
msg )
Value:
pred( __TNL_JOIN_STRINGS( val1, op, val2 ), msg, __FILE__, __TNL_PRETTY_FUNCTION, __LINE__, #val1, #val2, val1, val2 )

◆ __TNL_JOIN_STRINGS

#define __TNL_JOIN_STRINGS ( val1,
op,
val2 )
Value:
__STRING( val1 ) " " __STRING( op ) " " __STRING( val2 )

◆ TNL_ASSERT_EQ

#define TNL_ASSERT_EQ ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperEQ, ==, val1, val2, msg )

◆ TNL_ASSERT_FALSE

#define TNL_ASSERT_FALSE ( val,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperFalse, ==, val, false, msg )

◆ TNL_ASSERT_GE

#define TNL_ASSERT_GE ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperGE, >=, val1, val2, msg )

◆ TNL_ASSERT_GT

#define TNL_ASSERT_GT ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperGT, >, val1, val2, msg )

◆ TNL_ASSERT_LE

#define TNL_ASSERT_LE ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperLE, <=, val1, val2, msg )

◆ TNL_ASSERT_LT

#define TNL_ASSERT_LT ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperLT, <, val1, val2, msg )

◆ TNL_ASSERT_NE

#define TNL_ASSERT_NE ( val1,
val2,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperNE, !=, val1, val2, msg )

◆ TNL_ASSERT_TRUE

#define TNL_ASSERT_TRUE ( val,
msg )
Value:
__TNL_ASSERT_PRED2( ::TNL::Assert::cmpHelperTrue, ==, val, true, msg )

◆ TNL_IMPL_CMP_HELPER_

#define TNL_IMPL_CMP_HELPER_ ( op_name,
op )
Value:
template< typename T1, typename T2 > \
__cuda_callable__ \
void cmpHelper##op_name( const char* assertion, \
const char* message, \
const char* file, \
const char* function, \
int line, \
const char* expr1, \
const char* expr2, \
const T1& val1, \
const T2& val2 ) \
{ \
if( ! ( (val1) op( val2 ) ) ) \
::TNL::Assert::cmpHelperOpFailure( assertion, message, file, function, line, expr1, expr2, val1, val2, #op ); \
}