Boost logo

Boost Users :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2005-09-30 09:16:25


On Sep 29, 2005, at 10:11 AM, Andy Little wrote:

>
> Hi,
>
> In Mathematical Special Functions, why are the functions not template
> specialisations?

At the risk of being irritating, I'm going to ask just the opposite
question. ;-)

Why is hypot (for example) templated?

template <class T>
T hypot(T x, T y);

If the intent is to implement 8.16.4 (from N1836), I don't think this
does it. Consider this test for example:

double x = hypot(99., 20);
assert(x == 101.);

Or this one:

double x = hypot(99, 20);
assert(x == 101.);

Or <gag> this one:

double x = hypot(float(99), char(20));
assert(x == 101.);

Also do we want to support infinities and nans?

assert(hypot(INFINITY, sqrt(-1.)) == INFINITY);

-Howard


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net