BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Assertion.h File Reference
#include "ers/Issue.h"
#include <stdio.h>

Go to the source code of this file.

Classes

class  ers::Assertion
 This Issue represents a basic assertion. More...
struct  ers::Compile_time_error< true >
 compile time error structure More...

Namespaces

namespace  ers

Macros

#define ERS_STATIC_ASSERT(expr)
#define ERS_ASSERT(expr, ...)

Detailed Description

This file defines the assertion class and the associated macros.

Definition in file Event/ers/include/ers/Assertion.h.

Macro Definition Documentation

◆ ERS_ASSERT

#define ERS_ASSERT ( expr,
... )
Value:
{ \
if ( !( expr ) ) \
{ \
char assertion_buffer[256]; \
snprintf( assertion_buffer, sizeof( assertion_buffer ), __VA_ARGS__ ); \
ers::Assertion failed_assertion( ERS_HERE, ers::error, #expr, assertion_buffer, \
false ); \
throw failed_assertion; \
} \
}
This Issue represents a basic assertion.

if e is not true, then an issue of type ers::Asertion is thrown with message msg. The msg is actually a formatting string, like printf, that can be used with subsequent parameters. If the compiler is gcc, then the transient field of the assertion is set according to the transcience of the expression. This means that if the expression is detected by the compiler as being constant,

Note
This macro is disabled if the N_ERS_ASSERT macro is defined

Definition at line 102 of file Event/ers/include/ers/Assertion.h.

102# define ERS_ASSERT( expr, ... ) \
103 { \
104 if ( !( expr ) ) \
105 { \
106 char assertion_buffer[256]; \
107 snprintf( assertion_buffer, sizeof( assertion_buffer ), __VA_ARGS__ ); \
108 ers::Assertion failed_assertion( ERS_HERE, ers::error, #expr, assertion_buffer, \
109 false ); \
110 throw failed_assertion; \
111 } \
112 }

Referenced by ers::IssueFactory::build().

◆ ERS_STATIC_ASSERT

#define ERS_STATIC_ASSERT ( expr)
Value:
{ \
ers::Compile_time_error<( ( expr ) != 0 )> ERROR_ASSERTION_FAILED; \
(void)ERROR_ASSERTION_FAILED; \
}
compile time error structure.

Compile time assertion can only be done on constant factors (i.e compile-time known quantities).

Definition at line 71 of file Event/ers/include/ers/Assertion.h.

71# define ERS_STATIC_ASSERT( expr ) \
72 { \
73 ers::Compile_time_error<( ( expr ) != 0 )> ERROR_ASSERTION_FAILED; \
74 (void)ERROR_ASSERTION_FAILED; \
75 }

Referenced by main().