Boost logo

Boost :

From: Hugo Duncan (hugoduncan_at_[hidden])
Date: 2007-11-29 17:36:55


Hi,

I was wanting to check two boost::numeric::interval's for closeness, but
find I get a compile error. The below fails to compile, with the error
messages shown.

I believe this is because
   i) the comparison operator for interval is templated,
  ii) boost.test wraps one of the values with a readonly_property
and therefore the template is not an exact match. Changing the tolerance
to an interval does not change anything. This is with MSVC8 and with gcc
3.4.4 on windows.

Is this a bug, a missing feature - or am I misusing BOOST_CHECK_CLOSE ?

#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include "boost/numeric/interval.hpp"
#include "boost/numeric/interval/io.hpp"
using boost::unit_test::test_suite;

BOOST_AUTO_TEST_CASE(test_interval)
{
   boost::numeric::interval<double> v1=1;
   boost::numeric::interval<double> v2=1;
   BOOST_CHECK_CLOSE(v1,v2,1e-5);
}

c:\cygwin\home\duncan\boost\boost/test/floating_point_comparison.hpp(184)
: error C2679: binary '<=' : no operator found which takes a right-hand
operand of type 'const boost::unit_test::readonly_property<PropertyType>'
(or there is no acceptable conversion)
         with
         [
             PropertyType=boost::numeric::interval<double>
         ]
         c:\cygwin\home\duncan\boost\boost/numeric/interval/interval.hpp(82):
could be 'bool boost::numeric::interval<T>::operator <=(const
boost::numeric::interval<T>::interval_holder &) const'
         with
         [
             T=double
         ]
         c:\cygwin\home\duncan\boost\boost/numeric/interval/interval.hpp(89):
or 'bool boost::numeric::interval<T>::operator <=(const
boost::numeric::interval<T>::number_holder &) const'
         with
         [
             T=double
         ]
         while trying to match the argument list
'(boost::numeric::interval<T>, const
boost::unit_test::readonly_property<PropertyType>)'
         with
         [
             T=double
         ]
         and
         [
             PropertyType=boost::numeric::interval<double>
         ]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk