Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2006-07-24 11:49:11


I'm using Boost.Test, specifically BOOST_CHECK_CLOSE with non-built-in
floating point types. In particular I have a type "real_concept" that
models the concepts I want an arbitrary real number type to adhere to. This
type does *not* specialise std::numeric_limits: deliberately so because I
want to support types with whose precision varies at runtime. This causes a
problem inside safe_fpt_division which uses std::numeric_limits without the
check to see if it's specialised or not. In turn this causes almost all
comparisons using real_concept to succeed because safe_fpt_division will
almost always return 0 for real_concept.

The obvious fix is simply to place the numeric_limits checks inside an
if(std::numeric_limits<FPT>::is_specialized) block, and to perform no safety
checks in this case and just go ahead and perform the division regardless
(there are no checks that can be performed in this case anyway).

Thanks, John.


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