forked from boostorg/integer
Test mpz_class when available.
And fix errors compiling with that type.
This commit is contained in:
@ -336,9 +336,9 @@ namespace boost {
|
|||||||
|
|
||||||
unsigned shifts = 0;
|
unsigned shifts = 0;
|
||||||
|
|
||||||
if(!u)
|
if(u == T(0))
|
||||||
return v;
|
return v;
|
||||||
if(!v)
|
if(v == T(0))
|
||||||
return u;
|
return u;
|
||||||
|
|
||||||
shifts = constexpr_min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
|
shifts = constexpr_min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
|
||||||
@ -347,9 +347,9 @@ namespace boost {
|
|||||||
{
|
{
|
||||||
u %= v;
|
u %= v;
|
||||||
v -= u;
|
v -= u;
|
||||||
if(!u)
|
if(u == T(0))
|
||||||
return v << shifts;
|
return v << shifts;
|
||||||
if(!v)
|
if(v == T(0))
|
||||||
return u << shifts;
|
return u << shifts;
|
||||||
gcd_traits<T>::make_odd(u);
|
gcd_traits<T>::make_odd(u);
|
||||||
gcd_traits<T>::make_odd(v);
|
gcd_traits<T>::make_odd(v);
|
||||||
|
@ -6,6 +6,9 @@ import testing ;
|
|||||||
|
|
||||||
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
|
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
|
||||||
|
|
||||||
|
obj has_gmpxx : has_gmpxx.cpp ;
|
||||||
|
explicit has_gmpxx ;
|
||||||
|
|
||||||
test-suite integer
|
test-suite integer
|
||||||
:
|
:
|
||||||
[ run integer_traits_test.cpp ]
|
[ run integer_traits_test.cpp ]
|
||||||
@ -28,5 +31,5 @@ test-suite integer
|
|||||||
[ compile-fail fail_uint_fast.cpp ]
|
[ compile-fail fail_uint_fast.cpp ]
|
||||||
[ compile-fail fail_uint_least.cpp ]
|
[ compile-fail fail_uint_least.cpp ]
|
||||||
[ compile-fail fail_uint_65.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 <limits> // for std::numeric_limits
|
||||||
#include <ostream> // for std::basic_ostream
|
#include <ostream> // for std::basic_ostream
|
||||||
|
|
||||||
|
#ifdef BOOST_INTEGER_HAS_GMPXX_H
|
||||||
|
#include <gmpxx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -556,11 +560,11 @@ template <class T> void gcd_and_lcm_on_rationals()
|
|||||||
test<boost::multiprecision::int512_t>();
|
test<boost::multiprecision::int512_t>();
|
||||||
|
|
||||||
#ifdef BOOST_HAS_LONG_LONG
|
#ifdef BOOST_HAS_LONG_LONG
|
||||||
# define TEST_SIGNED( test ) \
|
# define TEST_SIGNED__( test ) \
|
||||||
TEST_SIGNED_( test ) \
|
TEST_SIGNED_( test ) \
|
||||||
test<boost::long_long_type>();
|
test<boost::long_long_type>();
|
||||||
#elif defined(BOOST_HAS_MS_INT64)
|
#elif defined(BOOST_HAS_MS_INT64)
|
||||||
# define TEST_SIGNED( test ) \
|
# define TEST_SIGNED__( test ) \
|
||||||
TEST_SIGNED_( test ) \
|
TEST_SIGNED_( test ) \
|
||||||
test<__int64>();
|
test<__int64>();
|
||||||
#endif
|
#endif
|
||||||
@ -584,6 +588,14 @@ template <class T> void gcd_and_lcm_on_rationals()
|
|||||||
test<unsigned __int64>();
|
test<unsigned __int64>();
|
||||||
#endif
|
#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()
|
int main()
|
||||||
{
|
{
|
||||||
TEST_SIGNED(gcd_int_test)
|
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>
|
||||||
|
|
Reference in New Issue
Block a user