|
Boost : |
From: Daniel Frey (d.frey_at_[hidden])
Date: 2005-11-13 10:09:15
Gennadiy Rozental wrote:
> Ok. So be it. Actually An ideal solution would be somethind like:
>
> BOOST_CHECK_CLOSE( a, b , 0.5% ) - test in percents
> BOOST_CHECK_CLOSE( a, b , 0.05) - test in epsilon
>
> But I couldn't figure out how implement it
Maybe this idea helps:
#include <iostream>
using namespace std;
struct Null { Null operator+() const { return Null(); } } null;
template< typename T >
T operator+( const T& v, const Null& ) { return v; }
template< typename T >
T operator%( const T& v, const Null& ) { return v / 100; }
#define TEST( X ) (X+null)
int main()
{
cout << TEST( 0.5% ) << endl
<< TEST( 0.05 ) << endl;
}
Regards, Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk