? diff.txt cvs diff: Diffing . Index: common_factor_test.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/math/test/common_factor_test.cpp,v retrieving revision 1.4.4.1 diff -u -r1.4.4.1 common_factor_test.cpp --- common_factor_test.cpp 23 Nov 2006 08:16:42 -0000 1.4.4.1 +++ common_factor_test.cpp 27 Nov 2006 13:09:33 -0000 @@ -20,19 +20,35 @@ #include // for boost::math::gcd, etc. #include // for boost::mpl::list #include -#include -#include #include // for std::basic_istream #include // for std::numeric_limits #include // for std::basic_ostream +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +// These operators are missing in VC6: +namespace std{ +template +std::basic_ostream& operator << (std::basic_ostream& os, const __int64& x) +{ + return os << double(x); +} +template +std::basic_ostream& operator << (std::basic_ostream& os, const unsigned __int64& x) +{ + return os << double(x); +} +} +#endif + +#include +#include namespace { // TODO: add polynominal/non-real type; especially after any switch to the // binary-GCD algorithm for built-in types - +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS // Custom integer class (template) template < typename IntType, int ID = 0 > class my_wrapped_integer @@ -50,7 +66,7 @@ // Template parameters typedef IntType int_type; - static int const id = ID; + BOOST_STATIC_CONSTANT(int, id = ID); // Lifetime management (use automatic destructor and copy constructor) my_wrapped_integer( int_type const &v = int_type() ) : v_( v ) {} @@ -93,7 +109,6 @@ friend std::basic_ostream & operator <<( std::basic_ostream &o, self_type const &x ) { return o << x.v_; } - }; // my_wrapped_integer template < typename IntType, int ID > @@ -105,6 +120,16 @@ typedef my_wrapped_integer MyInt2; typedef my_wrapped_integer MyUnsigned2; +#endif // BOOST_NO_MEMBER_TEMPLATE_FRIENDS + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1310) +// These explicit instantiations work around a strange VC6/7 bug: +template my_wrapped_integer; +template my_wrapped_integer; +template my_wrapped_integer; +template my_wrapped_integer; +#endif + // Various types to test with each GCD/LCM typedef ::boost::mpl::list signed_test_types; +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + MyInt1 +#else + long +#endif +> signed_test_types; typedef ::boost::mpl::list unsigned_test_types; +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + MyUnsigned1, MyUnsigned2 +#else + unsigned long +#endif +> unsigned_test_types; } // namespace @@ -128,6 +163,7 @@ // Specialize numeric_limits for _some_ of our types namespace std { +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS template < > class numeric_limits< MyInt1 > @@ -136,43 +172,43 @@ typedef numeric_limits limits_type; public: - static const bool is_specialized = limits_type::is_specialized; + BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized); static MyInt1 min() throw() { return limits_type::min(); } static MyInt1 max() throw() { return limits_type::max(); } - static const int digits = limits_type::digits; - static const int digits10 = limits_type::digits10; - static const bool is_signed = limits_type::is_signed; - static const bool is_integer = limits_type::is_integer; - static const bool is_exact = limits_type::is_exact; - static const int radix = limits_type::radix; + BOOST_STATIC_CONSTANT(int, digits = limits_type::digits); + BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10); + BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed); + BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer); + BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact); + BOOST_STATIC_CONSTANT(int, radix = limits_type::radix); static MyInt1 epsilon() throw() { return limits_type::epsilon(); } static MyInt1 round_error() throw() { return limits_type::round_error(); } - static const int min_exponent = limits_type::min_exponent; - static const int min_exponent10 = limits_type::min_exponent10; - static const int max_exponent = limits_type::max_exponent; - static const int max_exponent10 = limits_type::max_exponent10; - - static const bool has_infinity = limits_type::has_infinity; - static const bool has_quiet_NaN = limits_type::has_quiet_NaN; - static const bool has_signaling_NaN = limits_type::has_signaling_NaN; - static const float_denorm_style has_denorm = limits_type::has_denorm; - static const bool has_denorm_loss = limits_type::has_denorm_loss; + BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent); + BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10); + BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent); + BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10); + + BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity); + BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN); + BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN); + BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm); + BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss); static MyInt1 infinity() throw() { return limits_type::infinity(); } static MyInt1 quiet_NaN() throw() { return limits_type::quiet_NaN(); } static MyInt1 signaling_NaN() throw() {return limits_type::signaling_NaN();} static MyInt1 denorm_min() throw() { return limits_type::denorm_min(); } - static const bool is_iec559 = limits_type::is_iec559; - static const bool is_bounded = limits_type::is_bounded; - static const bool is_modulo = limits_type::is_modulo; - - static const bool traps = limits_type::traps; - static const bool tinyness_before = limits_type::tinyness_before; - static const float_round_style round_style = limits_type::round_style; + BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559); + BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded); + BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo); + + BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps); + BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before); + BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style); }; // std::numeric_limits @@ -183,30 +219,30 @@ typedef numeric_limits limits_type; public: - static const bool is_specialized = limits_type::is_specialized; + BOOST_STATIC_CONSTANT(bool, is_specialized = limits_type::is_specialized); static MyUnsigned1 min() throw() { return limits_type::min(); } static MyUnsigned1 max() throw() { return limits_type::max(); } - static const int digits = limits_type::digits; - static const int digits10 = limits_type::digits10; - static const bool is_signed = limits_type::is_signed; - static const bool is_integer = limits_type::is_integer; - static const bool is_exact = limits_type::is_exact; - static const int radix = limits_type::radix; + BOOST_STATIC_CONSTANT(int, digits = limits_type::digits); + BOOST_STATIC_CONSTANT(int, digits10 = limits_type::digits10); + BOOST_STATIC_CONSTANT(bool, is_signed = limits_type::is_signed); + BOOST_STATIC_CONSTANT(bool, is_integer = limits_type::is_integer); + BOOST_STATIC_CONSTANT(bool, is_exact = limits_type::is_exact); + BOOST_STATIC_CONSTANT(int, radix = limits_type::radix); static MyUnsigned1 epsilon() throw() { return limits_type::epsilon(); } static MyUnsigned1 round_error() throw(){return limits_type::round_error();} - static const int min_exponent = limits_type::min_exponent; - static const int min_exponent10 = limits_type::min_exponent10; - static const int max_exponent = limits_type::max_exponent; - static const int max_exponent10 = limits_type::max_exponent10; - - static const bool has_infinity = limits_type::has_infinity; - static const bool has_quiet_NaN = limits_type::has_quiet_NaN; - static const bool has_signaling_NaN = limits_type::has_signaling_NaN; - static const float_denorm_style has_denorm = limits_type::has_denorm; - static const bool has_denorm_loss = limits_type::has_denorm_loss; + BOOST_STATIC_CONSTANT(int, min_exponent = limits_type::min_exponent); + BOOST_STATIC_CONSTANT(int, min_exponent10 = limits_type::min_exponent10); + BOOST_STATIC_CONSTANT(int, max_exponent = limits_type::max_exponent); + BOOST_STATIC_CONSTANT(int, max_exponent10 = limits_type::max_exponent10); + + BOOST_STATIC_CONSTANT(bool, has_infinity = limits_type::has_infinity); + BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = limits_type::has_quiet_NaN); + BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = limits_type::has_signaling_NaN); + BOOST_STATIC_CONSTANT(float_denorm_style, has_denorm = limits_type::has_denorm); + BOOST_STATIC_CONSTANT(bool, has_denorm_loss = limits_type::has_denorm_loss); static MyUnsigned1 infinity() throw() { return limits_type::infinity(); } static MyUnsigned1 quiet_NaN() throw() { return limits_type::quiet_NaN(); } @@ -214,16 +250,16 @@ { return limits_type::signaling_NaN(); } static MyUnsigned1 denorm_min() throw(){ return limits_type::denorm_min(); } - static const bool is_iec559 = limits_type::is_iec559; - static const bool is_bounded = limits_type::is_bounded; - static const bool is_modulo = limits_type::is_modulo; - - static const bool traps = limits_type::traps; - static const bool tinyness_before = limits_type::tinyness_before; - static const float_round_style round_style = limits_type::round_style; + BOOST_STATIC_CONSTANT(bool, is_iec559 = limits_type::is_iec559); + BOOST_STATIC_CONSTANT(bool, is_bounded = limits_type::is_bounded); + BOOST_STATIC_CONSTANT(bool, is_modulo = limits_type::is_modulo); + + BOOST_STATIC_CONSTANT(bool, traps = limits_type::traps); + BOOST_STATIC_CONSTANT(bool, tinyness_before = limits_type::tinyness_before); + BOOST_STATIC_CONSTANT(float_round_style, round_style = limits_type::round_style); }; // std::numeric_limits - +#endif // BOOST_NO_MEMBER_TEMPLATE_FRIENDS } // namespace std @@ -266,7 +302,7 @@ #else using namespace boost::math; #endif - +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS // The regular signed-integer GCD function performs the unsigned version, // then does an absolute-value on the result. Signed types that are not // marked as such (due to no std::numeric_limits specialization) may be off @@ -287,6 +323,7 @@ BOOST_CHECK_EQUAL( abs(gcd( 3, 7 )), MyInt2( 1) ); BOOST_CHECK_EQUAL( abs(gcd( 8, 9 )), MyInt2( 1) ); BOOST_CHECK_EQUAL( abs(gcd( 7, 49 )), MyInt2( 7) ); +#endif } // GCD on unsigned integer types @@ -377,7 +414,7 @@ #else using namespace boost::math; #endif - +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS // The regular signed-integer LCM function performs the unsigned version, // then does an absolute-value on the result. Signed types that are not // marked as such (due to no std::numeric_limits specialization) may be off @@ -398,6 +435,7 @@ BOOST_CHECK_EQUAL( abs(lcm( 3, 7 )), MyInt2(21) ); BOOST_CHECK_EQUAL( abs(lcm( 8, 9 )), MyInt2(72) ); BOOST_CHECK_EQUAL( abs(lcm( 7, 49 )), MyInt2(49) ); +#endif // BOOST_NO_MEMBER_TEMPLATE_FRIENDS } // LCM on unsigned integer types