Test mpz_class when available.
And fix errors compiling with that type.
This commit is contained in:
parent
84ded579f3
commit
7ccb820893
@ -336,9 +336,9 @@ namespace boost {
|
||||
|
||||
unsigned shifts = 0;
|
||||
|
||||
if(!u)
|
||||
if(u == T(0))
|
||||
return v;
|
||||
if(!v)
|
||||
if(v == T(0))
|
||||
return u;
|
||||
|
||||
shifts = constexpr_min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
|
||||
@ -347,9 +347,9 @@ namespace boost {
|
||||
{
|
||||
u %= v;
|
||||
v -= u;
|
||||
if(!u)
|
||||
if(u == T(0))
|
||||
return v << shifts;
|
||||
if(!v)
|
||||
if(v == T(0))
|
||||
return u << shifts;
|
||||
gcd_traits<T>::make_odd(u);
|
||||
gcd_traits<T>::make_odd(v);
|
||||
|
@ -6,6 +6,9 @@ import testing ;
|
||||
|
||||
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
|
||||
|
||||
obj has_gmpxx : has_gmpxx.cpp ;
|
||||
explicit has_gmpxx ;
|
||||
|
||||
test-suite integer
|
||||
:
|
||||
[ run integer_traits_test.cpp ]
|
||||
@ -28,5 +31,5 @@ test-suite integer
|
||||
[ compile-fail fail_uint_fast.cpp ]
|
||||
[ compile-fail fail_uint_least.cpp ]
|
||||
[ compile-fail fail_uint_65.cpp ]
|
||||
[ run common_factor_test.cpp ]
|
||||
[ run common_factor_test.cpp : : : [ check-target-builds "Checking for gmpxx.h" : <define>BOOST_INTEGER_HAS_GMPXX_H=1 ] ]
|
||||
;
|
||||
|
@ -31,6 +31,10 @@
|
||||
#include <limits> // for std::numeric_limits
|
||||
#include <ostream> // for std::basic_ostream
|
||||
|
||||
#ifdef BOOST_INTEGER_HAS_GMPXX_H
|
||||
#include <gmpxx.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
@ -556,11 +560,11 @@ template <class T> void gcd_and_lcm_on_rationals()
|
||||
test<boost::multiprecision::int512_t>();
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
# define TEST_SIGNED( test ) \
|
||||
# define TEST_SIGNED__( test ) \
|
||||
TEST_SIGNED_( test ) \
|
||||
test<boost::long_long_type>();
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
# define TEST_SIGNED( test ) \
|
||||
# define TEST_SIGNED__( test ) \
|
||||
TEST_SIGNED_( test ) \
|
||||
test<__int64>();
|
||||
#endif
|
||||
@ -584,6 +588,14 @@ template <class T> void gcd_and_lcm_on_rationals()
|
||||
test<unsigned __int64>();
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_INTEGER_HAS_GMPXX_H
|
||||
# define TEST_SIGNED(test)\
|
||||
TEST_SIGNED__(test)\
|
||||
test<mpz_class>();
|
||||
#else
|
||||
# define TEST_SIGNED(test) TEST_SIGNED__(test)
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SIGNED(gcd_int_test)
|
||||
|
7
test/has_gmpxx.cpp
Normal file
7
test/has_gmpxx.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright John Maddock 2008.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <gmpxx.h>
|
||||
|
Loading…
Reference in New Issue
Block a user