|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 1999-12-17 20:29:36
At 10:08 PM 12/17/99 -0000, Paul Moore wrote:
>Right. Attached is the final version of rational. I say final, but
the abs()
>stuff is *still* fairly fragile. It works on MSVC, but that's all I
can say.
>I would appreciate comments on how other compilers fare.
Paul,
Here is a report on compiling rational_example.cpp with Metrowerks
CodeWarrior 5.2:
* #ifdef _MSC_VER is true, causing the Microsoft hacks to be
invoked, which of course fail with the more standards conforming CW
compiler.
Several companies (Metrowerks, Intel, at least, probably more)
predefine _MSC_VER in an attempt to be compatible. Sigh.
* After commenting out the above, tried again and got:
Error : illegal access to protected/private member
(instantiating: 'boost::?$abs_at_H(const boost::rational<int> &)')
rational.hpp line 299 return rational<IntType>(abs(r.num),
r.den);
(r.num) was underlined.
* After commenting out "private:" to hack around the above, the
compile was clean.
* Ran apparently OK with the output:
1/2+1/2=1/1
1/1-1/2=1/2
2/1*1/2=1/1
1/1/1/2=2/1
abs(-1/2)=1/2
2 * 2147483647/2=2147483647 (rational: 2147483647/1)
pi = 3.14286 (nearly)
Sorry; I was pressed for time and did nothing more.
Hope the above helps.
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk