Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-11-02 05:10:45


--- In boost_at_y..., "Moore, Paul" <paul.moore_at_a...> wrote:
> From: helmut.zeisel_at_a...

> But I can't
> honestly believe that they are likely to be using many different
rational
> types, based on many integer types, and many float types (which is
the only
> time the genericicity of using the same name really helps). So why
not just
> write a function?

It might be true that one day we will have only one rational type,
but we have already three float types
(float, double, long double)
and may have more in the future
(e.g. fixed point, high precision).
I like a template-version like rational_cast<double>
much more than a different name like double_rational_cast,
drational_cast or whatever.
So IMHO genericicity is useful.

> >
> > template<typname Float, typename T> void algorithm(T& t)
> > {
> > ...
> > Float F = xxx_cast<F>(t)
> > ...
> > }
> >
> > If T is either int or rational<int>, what should
> > "xxx_cast" be?
>
> "my_cast".
>
> Seriously - what is the problem with the user defining a helper
function?
>

Nothing,
with the exception that a good general framework
is preferable to many singular solutions.

Helmut


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