forked from boostorg/integer
Use std::enable_if to enable SFINAE rather than static_assert
This commit is contained in:
@ -22,16 +22,12 @@ struct euclidean_result_t {
|
||||
Z y;
|
||||
};
|
||||
|
||||
template<class Z>
|
||||
euclidean_result_t<Z> extended_euclidean(Z m, Z n)
|
||||
{
|
||||
using std::numeric_limits;
|
||||
static_assert(numeric_limits<Z>::is_integer,
|
||||
"The extended Euclidean algorithm works on integral types.\n");
|
||||
|
||||
static_assert(numeric_limits<Z>::is_signed,
|
||||
"The extended Euclidean algorithm only works on signed integer types.\n");
|
||||
|
||||
template<class Z>
|
||||
euclidean_result_t<typename std::enable_if<numeric_limits< Z >::is_signed, Z>::type>
|
||||
extended_euclidean(Z m, Z n)
|
||||
{
|
||||
if (m < 1 || n < 1)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Arguments must be strictly positive.\n"));
|
||||
|
@ -17,8 +17,8 @@ test-suite integer
|
||||
[ run integer_mask_test.cpp ]
|
||||
[ run static_log2_test.cpp ]
|
||||
[ run static_min_max_test.cpp ]
|
||||
[ run extended_euclidean_test.cpp : : : [ requires cxx11_unified_initialization_syntax ] ]
|
||||
[ run mod_inverse_test.cpp : : : [ requires cxx11_unified_initialization_syntax ] ]
|
||||
[ run extended_euclidean_test.cpp : : : [ requires cxx11_unified_initialization_syntax sfinae_expr ] ]
|
||||
[ run mod_inverse_test.cpp : : : [ requires cxx11_unified_initialization_syntax sfinae_expr ] ]
|
||||
[ compile integer_traits_include_test.cpp ]
|
||||
[ compile integer_include_test.cpp ]
|
||||
[ compile integer_mask_include_test.cpp ]
|
||||
|
Reference in New Issue
Block a user