|
Boost : |
From: Alan Stokes (alan_at_[hidden])
Date: 2004-01-07 10:13:37
Michael D. Borghardt wrote:
> ====> new lines
>
> template <>
> struct greater_than_type_max<false, true>
> {
> template <class X, class Y>
> static inline bool check(X x, Y y_max)
> {
> return x >=0
> // && static_cast<X>(static_cast<Y>(x)) != x; } // orignal line
> ===> && ((static_cast<X>(static_cast<Y>(x)) != x)
> ===> || (sizeof(Y) >= sizeof(X) ? static_cast<Y>(x) >
> y_max : x > static_cast<X>(y_max)));
> }
That still retains the static_cast<X>(static_cast<T>(x)) != x from the original.
I've just come across a problem relating to this with the original numeric_cast.
numeric_cast<unsigned>(1.5) throws, when it should succeed (and return 1U). This
is because static_cast<double>(static_cast<unsigned>(1.5)) is 1.0, not 1.5.
I think the same problem must exist in your reformulation. Do you have a test
case for this? Can you do away with the original test altogether?
- Alan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk