25 #ifndef WPRECONDITIONNOTMET_H
26 #define WPRECONDITIONNOTMET_H
32 #include "../WException.h"
65 inline void __WPrecondImpl( std::string
const& expr, std::string
const& msg )
68 s <<
"Function precondition not met: " << expr;
86 template<
typename T1,
typename T2 >
87 void __WPrecondDiffersImpl( std::string
const& expr1, std::string
const& expr2, T1
const& value1, T2
const& value2 )
89 if( value1 == value2 )
92 s <<
"Function precondition not met: \n";
93 s <<
"Expected " << expr1 <<
" to differ from " << expr2 <<
", yet " << value1
109 template<
typename T1,
typename T2 >
110 void __WPrecondEqualsImpl( std::string
const& expr1, std::string
const& expr2, T1
const& value1, T2
const& value2 )
112 if( !( value1 == value2 ) )
115 s <<
"Function precondition not met: \n";
116 s <<
"Expected " << expr1 <<
" to be equal to " << expr2 <<
", yet " << value1
132 template<
typename T1,
typename T2 >
133 void __WPrecondLessImpl( std::string
const& expr1, std::string
const& expr2, T1
const& value1, T2
const& value2 )
135 if( !( value1 < value2 ) )
138 s <<
"Function precondition not met: \n";
139 s <<
"Expected " << expr1 <<
" to be smaller than " << expr2 <<
", yet " << value1
147 #define WPrecond( expr, msg ) ( ( expr ) ? ( ( void )0 ) : ( ::utility::__WPrecondImpl( #expr, msg ) ) )
149 #define WPrecondDiffers( expr1, expr2 ) ( ::utility::__WPrecondDiffersImpl( #expr1, #expr2, ( expr1 ), ( expr2 ) ) )
151 #define WPrecondEquals( expr1, expr2 ) ( ::utility::__WPrecondEqualsImpl( #expr1, #expr2, ( expr1 ), ( expr2 ) ) )
153 #define WPrecondLess( expr1, expr2 ) ( ::utility::__WPrecondLessImpl( #expr1, #expr2, ( expr1 ), ( expr2 ) ) )
An exception that gets thrown when preconditions of a function are not met.
WPreconditionNotMet(std::string const &msg)
Constructor.
virtual ~WPreconditionNotMet()
Destructor.