From: Daryle Walker (darylew_at_[hidden])
Date: 2001-02-06 18:40:45
on 2/5/01 8:28 PM, Paul Moore at gustav_at_[hidden] wrote:
> 1. Much updated documentation, including sections on rationale
> (which may help explain some of the issues behind the other
> changes below) and performance (giving some indications for users-
> of user-defined integer types).
The documentation should have a Contents section, since it's so long.
In the "Swap operation" section, you mention a (full) specialization of the
"std::swap" function. Isn't specialization guaranteed just for class
templates in the "std" namespace, with function templates in "std" still
kind-of ambiguous? (When this came up before, I think some people here
decided to screw it and define the specialization anyway, no matter its
> 2. Reworked abs() which no longer relies on Koenig lookup (see
> the rationale for details).
> 3. Updated operator>>, enforcing stricter format checks.
I have something like "boost::detail::resetter" in the in-progress
"more_io.zip" library (in the vault). I guess you can update when that
sub-library is finalized.
Shouldn't the I/O operators be templated on character and traits types?
You no longer allow a rational to be just a numerator (i.e. if there's no
following '/' then use the first read number as the numerator with a
denominator of 1), any particular reason? Should you put that reason in the
The output operator doesn't take item widths into account (i.e. it'll space
just the numerator, not the whole fraction). You could do something like:
template < typename IntType, typename Ch, class Tr >
std::basic_ostream<Ch, Tr> &
std::basic_ostream<Ch, Tr> & os,
const rational<IntType> & r
std::basic_ostringstream<Ch, Tr> s;
s.copyfmt( os );
s.width( 0 );
s << r.numerator() << '/' << r.denominator();
return os << s.str();
This was basically ripped from Josuttis's C++ Standard Library book, which
also has an input example.
> 4. Includes Stephen Silver's regression test program (updated
> somewhat). In the longer term I intend to look at the Boost testing
> 5. Many updates for efficiency. However, the use of std::swap() in
> gcd() as an optimisation, which was previously discussed on the
> list, has been dropped (although it is still available if the user
> defines a macro symbol, BOOST_RATIONAL_USE_STD_SWAP) -
> see the rationale for details.
> 6. Lots of changes to make the code more robust when used with
> a user-defined IntType (again, thanks for much of this to Stephen
Thoughts on file "rational_example.cpp":
1. You have an option on the BOOST_NO_LIMITS macro that uses <limits> if
the macro isn't defined and <limits.h> if it is. Couldn't you just use the
latter header all the time (in its <climits> form)?
2. You use the _MSC_VER macro to option on the Microsoft Visual C++
compiler being used, due its infamous shortcomings. You should use the
BOOST_MSVC macro, since other Windows compilers may also define the former
macro, making it ambiguous. (Those other compilers may not have [all of]
You have a problem similar to  above in "rational_test.cpp," line 197.
(I guess the even better BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP macro isn't
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk