DCMTK  Version 3.6.9
OFFIS DICOM Toolkit
Macros
ofassert.h File Reference

Including run time and compile time assertion features and implementing fallback implementations for the ones that are not available. More...

Macros

#define OFstatic_assert(E, M)
 Assert a constant expression at compile time. More...
 

Detailed Description

Including run time and compile time assertion features and implementing fallback implementations for the ones that are not available.

Macro Definition Documentation

◆ OFstatic_assert

#define OFstatic_assert (   E,
 
)

Assert a constant expression at compile time.

Parameters
Ean expression that can be evaluated as a boolean constant at compile time.
Ma message that will be displayed in case the expression evaluates to OFFalse.

OFstatic_assert will check the expression E at compile time, emitting a compiler error if the expression evaluates to OFFalse. The statement will be ignored in case E evaluates to OFTrue, i.e. there will be no performance impact.

Remarks
OFstatic_assert will simply be defined as 'static_assert' if the feature is available and fallback to an implementation based on template specialization otherwise. Depending on what compiler is being used, the error emitted by the fallback implementation can become rather cryptic, e.g. not even containing the message given as 'M'.
Note
OFstatic_assert is a preprocessor macro. If static_assert is available, it will simply be another name for that, otherwise it will be a macro taking two arguments. This means you will have to put an expression containing one or more commas into parentheses '(' and ')', since the preprocessor will otherwise break the expression into more than one argument (at each ',').

Usage Example

typedef OFintegral_constant<size_t,24000> available_money;
typedef OFintegral_constant<size_t,36> dependability;
typedef OFintegral_constant<OFBool,(available_money::value * dependability::value > 25000000)> can_i_have_a_pony;
OFstatic_assert( can_i_have_a_pony::value, "no, you can't have a pony" );
#define OFstatic_assert(E, M)
Assert a constant expression at compile time.
Definition: ofassert.h:75
OFintegral_constant wraps a static constant of specified type.
Definition: oftraits.h:361


Generated on Wed Dec 11 2024 for DCMTK Version 3.6.9 by Doxygen 1.9.1