From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-05-09 13:06:56
Gerhard Wesp wrote:
> On Tue, May 09, 2006 at 06:04:31PM +0200, Tobias Schwinger wrote:
>>The code is more readable and more flexible. You don't have to be afraid
>>to break things when you change the type of a varaible, it either just
> I'm not convinced. What if you change a and b from "heavyweight"
> integer to built-in integer? Then the semantics of the your example
> rational c = a / b // where a and b are integers a=1 b=2
> c will then be zero.
Well, if you change the type to 'boost::path', the semantics change too... Granted, in the case you mention you'll have to know what you're doing.
The aim is, however, to make things so efficient that you wouldn't want to do it ;-).
If you can foresee that a or b might both be builtin types (e.g. in a template function) you can write:
rational c = convert(a) / b
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk