diff --git a/include/boost/integer/common_factor.hpp b/include/boost/integer/common_factor.hpp index 21a71e4..fab9199 100644 --- a/include/boost/integer/common_factor.hpp +++ b/include/boost/integer/common_factor.hpp @@ -7,10 +7,10 @@ // See http://www.boost.org for updates, documentation, and revision history. -#ifndef BOOST_MATH_COMMON_FACTOR_HPP -#define BOOST_MATH_COMMON_FACTOR_HPP +#ifndef BOOST_INTEGER_COMMON_FACTOR_HPP +#define BOOST_INTEGER_COMMON_FACTOR_HPP -#include -#include +#include +#include -#endif // BOOST_MATH_COMMON_FACTOR_HPP +#endif // BOOST_INTEGER_COMMON_FACTOR_HPP diff --git a/include/boost/integer/common_factor_ct.hpp b/include/boost/integer/common_factor_ct.hpp index bf58b94..0671d16 100644 --- a/include/boost/integer/common_factor_ct.hpp +++ b/include/boost/integer/common_factor_ct.hpp @@ -7,16 +7,15 @@ // See http://www.boost.org for updates, documentation, and revision history. -#ifndef BOOST_MATH_COMMON_FACTOR_CT_HPP -#define BOOST_MATH_COMMON_FACTOR_CT_HPP +#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP +#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP -#include // self include +#include // self include #include // for BOOST_STATIC_CONSTANT, etc. -#include namespace boost { -namespace math +namespace integer { // Implementation details --------------------------------------------------// @@ -76,22 +75,28 @@ namespace detail // Compile-time greatest common divisor evaluator class declaration --------// -template < static_gcd_type Value1, static_gcd_type Value2 > -struct static_gcd : public mpl::integral_c::value) > +template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd { -}; // boost::math::static_gcd + BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t::value) ); +}; // boost::integer::static_gcd +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) +template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value; +#endif // Compile-time least common multiple evaluator class declaration ----------// -template < static_gcd_type Value1, static_gcd_type Value2 > -struct static_lcm : public mpl::integral_c::value) > +template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm { -}; // boost::math::static_lcm + BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t::value) ); +}; // boost::integer::static_lcm +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) +template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value; +#endif -} // namespace math +} // namespace integer } // namespace boost -#endif // BOOST_MATH_COMMON_FACTOR_CT_HPP +#endif // BOOST_INTEGER_COMMON_FACTOR_CT_HPP diff --git a/include/boost/integer/common_factor_rt.hpp b/include/boost/integer/common_factor_rt.hpp index 10a92eb..c2b54db 100644 --- a/include/boost/integer/common_factor_rt.hpp +++ b/include/boost/integer/common_factor_rt.hpp @@ -12,10 +12,10 @@ // See http://www.boost.org for updates, documentation, and revision history. -#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP -#define BOOST_MATH_COMMON_FACTOR_RT_HPP +#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP +#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP -#include // self include +#include // self include #include // for BOOST_NESTED_TEMPLATE, etc. #include // for std::numeric_limits @@ -29,7 +29,7 @@ namespace boost { -namespace math +namespace integer { @@ -55,7 +55,7 @@ public: result_type operator ()( first_argument_type const &a, second_argument_type const &b ) const; -}; // boost::math::gcd_evaluator +}; // boost::integer::gcd_evaluator // Least common multiple evaluator class declaration -----------------------// @@ -71,7 +71,7 @@ public: result_type operator ()( first_argument_type const &a, second_argument_type const &b ) const; -}; // boost::math::lcm_evaluator +}; // boost::integer::lcm_evaluator // Implementation details --------------------------------------------------// @@ -450,11 +450,11 @@ lcm } -} // namespace math +} // namespace integer } // namespace boost #ifdef BOOST_MSVC #pragma warning(pop) #endif -#endif // BOOST_MATH_COMMON_FACTOR_RT_HPP +#endif // BOOST_INTEGER_COMMON_FACTOR_RT_HPP diff --git a/include/boost/integer_fwd.hpp b/include/boost/integer_fwd.hpp index 20eff2b..10577ae 100644 --- a/include/boost/integer_fwd.hpp +++ b/include/boost/integer_fwd.hpp @@ -158,6 +158,29 @@ template struct static_unsigned_max; + +// From + +#ifdef BOOST_NO_INTEGRAL_INT64_T + typedef unsigned long static_gcd_type; +#else + typedef boost::uintmax_t static_gcd_type; +#endif + +template < static_gcd_type Value1, static_gcd_type Value2 > + struct static_gcd; +template < static_gcd_type Value1, static_gcd_type Value2 > + struct static_lcm; + + +// From + +template < typename IntegerType > + class gcd_evaluator; +template < typename IntegerType > + class lcm_evaluator; + + } // namespace boost diff --git a/test/common_factor_test.cpp b/test/common_factor_test.cpp index 1044b14..81ffc47 100644 --- a/test/common_factor_test.cpp +++ b/test/common_factor_test.cpp @@ -246,7 +246,7 @@ inline ostream& operator<<(ostream& os, unsigned __int64 i) // GCD on signed integer types template< class T > void gcd_int_test() // signed_test_types { - using boost::math::gcd; + using boost::integer::gcd; // Originally from Boost.Rational tests BOOST_TEST_EQ( gcd( 1, -1), static_cast( 1) ); @@ -270,7 +270,7 @@ template< class T > void gcd_int_test() // signed_test_types // GCD on unmarked signed integer type void gcd_unmarked_int_test() { - using boost::math::gcd; + using boost::integer::gcd; // The regular signed-integer GCD function performs the unsigned version, // then does an absolute-value on the result. Signed types that are not @@ -297,7 +297,7 @@ void gcd_unmarked_int_test() // GCD on unsigned integer types template< class T > void gcd_unsigned_test() // unsigned_test_types { - using boost::math::gcd; + using boost::integer::gcd; // Note that unmarked types (i.e. have no std::numeric_limits // specialization) are treated like non/unsigned types @@ -314,7 +314,7 @@ template< class T > void gcd_unsigned_test() // unsigned_test_types // GCD at compile-time void gcd_static_test() { - using boost::math::static_gcd; + using boost::integer::static_gcd; BOOST_TEST_EQ( (static_gcd< 1, 1>::value), 1 ); BOOST_TEST_EQ( (static_gcd< 0, 0>::value), 0 ); @@ -336,7 +336,7 @@ void gcd_static_test() // LCM on signed integer types template< class T > void lcm_int_test() // signed_test_types { - using boost::math::lcm; + using boost::integer::lcm; // Originally from Boost.Rational tests BOOST_TEST_EQ( lcm( 1, -1), static_cast( 1) ); @@ -360,7 +360,7 @@ template< class T > void lcm_int_test() // signed_test_types // LCM on unmarked signed integer type void lcm_unmarked_int_test() { - using boost::math::lcm; + using boost::integer::lcm; // The regular signed-integer LCM function performs the unsigned version, // then does an absolute-value on the result. Signed types that are not @@ -387,7 +387,7 @@ void lcm_unmarked_int_test() // LCM on unsigned integer types template< class T > void lcm_unsigned_test() // unsigned_test_types { - using boost::math::lcm; + using boost::integer::lcm; // Note that unmarked types (i.e. have no std::numeric_limits // specialization) are treated like non/unsigned types @@ -404,7 +404,7 @@ template< class T > void lcm_unsigned_test() // unsigned_test_types // LCM at compile-time void lcm_static_test() { - using boost::math::static_lcm; + using boost::integer::static_lcm; BOOST_TEST_EQ( (static_lcm< 1, 1>::value), 1 ); BOOST_TEST_EQ( (static_lcm< 0, 0>::value), 0 ); @@ -423,51 +423,51 @@ void lcm_static_test() // Various types to test with each GCD/LCM #define TEST_SIGNED_( test ) \ - test(); \ - test(); \ - test(); \ - test(); \ - test(); + test(); \ + test(); \ + test(); \ + test(); \ + test(); #ifdef BOOST_HAS_LONG_LONG # define TEST_SIGNED( test ) \ - TEST_SIGNED_( test ) \ - test(); + TEST_SIGNED_( test ) \ + test(); #elif defined(BOOST_HAS_MS_INT64) # define TEST_SIGNED( test ) \ - TEST_SIGNED_( test ) \ - test<__int64>(); + TEST_SIGNED_( test ) \ + test<__int64>(); #endif #define TEST_UNSIGNED_( test ) \ - test(); \ - test(); \ - test(); \ - test(); \ - test(); \ - test(); + test(); \ + test(); \ + test(); \ + test(); \ + test(); \ + test(); #ifdef BOOST_HAS_LONG_LONG # define TEST_UNSIGNED( test ) \ - TEST_UNSIGNED_( test ) \ - test(); + TEST_UNSIGNED_( test ) \ + test(); #elif defined(BOOST_HAS_MS_INT64) # define TEST_UNSIGNED( test ) \ - TEST_UNSIGNED_( test ) \ - test(); + TEST_UNSIGNED_( test ) \ + test(); #endif int main() { - TEST_SIGNED( gcd_int_test ) - gcd_unmarked_int_test(); - TEST_UNSIGNED( gcd_unsigned_test ) - gcd_static_test(); + TEST_SIGNED( gcd_int_test ) + gcd_unmarked_int_test(); + TEST_UNSIGNED( gcd_unsigned_test ) + gcd_static_test(); - TEST_SIGNED( lcm_int_test ) - lcm_unmarked_int_test(); - TEST_UNSIGNED( lcm_unsigned_test ) - lcm_static_test(); + TEST_SIGNED( lcm_int_test ) + lcm_unmarked_int_test(); + TEST_UNSIGNED( lcm_unsigned_test ) + lcm_static_test(); - return boost::report_errors(); + return boost::report_errors(); }