Opened 17 years ago

Closed 17 years ago

#443 closed Bugs (Fixed)

no Boolean conversion for boost::rational

Reported by: Daryle Walker Owned by: Jonathan Turkanis
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

The boost::rational class template, in header file <boost/
rational.hpp>, does not support conversion to a Boolean value.  It 
does have an "operator !" defined, though.  It is a surprise for a type 
to have one of these operations but not the other.  Currently code 
like "if ( !r )" works but not "if ( r )", which should be expected.  A 
solution is to add a conversion operator to a type that can be used in 
Boolean contexts, but as little else as possible.  A suggestion is to 
use a pointer-to-member (to data or function) type that is unique to 
each version of boost::rational, where the exact values are private.

Change History (1)

comment:1 by Daryle Walker, 17 years ago

Status: assignedclosed
Logged In: YES 
user_id=551024

I just submitted a fix; please re-open this bug if the
fix doesn't work.  The CVS versions for each file in
the fix are:
    BOOST_ROOT/boost/rational.hpp :1.16
    BOOST_ROOT/libs/rational/rational.html :1.7
    BOOST_ROOT/libs/rational/rational_test.cpp :1.18

Note: See TracTickets for help on using tickets.