0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

use templated assert

This commit is contained in:
Eliot Horowitz 2009-10-08 11:04:13 -04:00
parent a54742b3de
commit 23936952c1
2 changed files with 18 additions and 27 deletions

View File

@ -324,30 +324,8 @@ namespace mongo {
log() << _file << ":" << _line << " " << _aexp << " != " << _bexp << " ";
}
void MyAsserts::ae( double a , double b ){
void MyAsserts::_gotAssert(){
Result::cur->_asserts++;
if ( a == b )
return;
printLocation();
MyAssertionException * e = getBase();
e->ss << a << " != " << b << endl;
log() << e->ss.str() << endl;
throw e;
}
void MyAsserts::ae( string a , string b ){
Result::cur->_asserts++;
if ( a == b )
return;
printLocation();
MyAssertionException * e = getBase();
e->ss << a << " != " << b << endl;
log() << e->ss.str() << endl;
throw e;
}
}

View File

@ -151,14 +151,27 @@ namespace mongo {
: _aexp( aexp ) , _bexp( bexp ) , _file( file ) , _line( line ){
}
void ae( double a , double b );
void ae( string a , string b );
template<typename A,typename B>
void ae( A a , B b ){
_gotAssert();
if ( a == b )
return;
printLocation();
MyAssertionException * e = getBase();
e->ss << a << " != " << b << endl;
log() << e->ss.str() << endl;
throw e;
}
void printLocation();
private:
void _gotAssert();
MyAssertionException * getBase();
string _aexp;