|
Boost : |
From: Michael D. Borghardt (michael_at_[hidden])
Date: 2004-01-05 19:28:13
I assumed you wanted text
Testing Cases
c uc sc s us ss i ui si l ul sl
f d
c N 33 P 15 17 21 27 34 41 47 55 65
uc N 12 13 18 22 28 35 42 48 56 66
sc 6 N 16 19 23 29 36 43 1,2 57 67
s P P N 20 P 30 37 44 49 58 68
us P P 10 N 24 31 38 45 50 59 69 25
ss P P P 9 N 32 39 46 51 60 70
i P P P P P N 40 P 52 61 71 5
ui P P P P P 11 N 14 53 62 72
si P P P P P P 7 N 54 63 73
l P P P P P P P P N 64 P
ul P P P P P P P P 3,4,75 N 74
sl P P P P P P P P P 8 N
f P P P P P P P P P 26 P N
d P P P P P P P P P P P P N
columns are source
rows are targer
N Not applicable since converting to itself
P Pass - I have not checked all these
c char
uc unsigned char
sc signed char
s short
us unsigned short
ss signed short
i int
ui unsigned int
si signed int
l long
ul unsigned long
sl signed long
f float
d double
Tests 6 -9,15 -23, 26 - 73 use sources MAX value
Here is my latest table with the following changes
Test 10 -14,24,74, 75 use sources MIN value
Test 25 uses 500.5
Tests 52,53,54,62,71,72,73 are not tested as they have the same size on my
platform
The orginal source line fails tests
6-9,17,19,20,26,33,34,36,37,39,40,55,57,58,60,61,63,64 where each
uses the sources MAX value
====> 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)));
}
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200
// MSVC6 can't static_cast unsigned __int64 -> floating types
# define BOOST_UINT64_CAST(src_type) \
static inline bool check(src_type x, unsigned __int64) \
{ \
if (x < 0) return false; \
unsigned __int64 y = static_cast<unsigned __int64>(x); \
bool odd = y & 0x1; \
__int64 div2 = static_cast<__int64>(y >> 1); \
return ((static_cast<src_type>(div2) * 2.0) + odd) != x; \
}
BOOST_UINT64_CAST(long double);
BOOST_UINT64_CAST(double);
BOOST_UINT64_CAST(float);
# undef BOOST_UINT64_CAST
# endif
};
template <>
struct greater_than_type_max<false, false>
{
template <class X, class Y>
static inline bool check(X x, Y y_max)
{
====> return (sizeof(Y) > sizeof(X) ? static_cast<Y>(x) > y_max : x >
static_cast<X>(y_max));}
// return static_cast<X>(static_cast<Y>(x)) != x; // orignal line
};
With my changes they all the ones that pass still pass and the ones that
failed now pass.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk