From df7adb52caa56aa7573c1e9b867c8740fb9ba9d6 Mon Sep 17 00:00:00 2001 From: Nick Thompson Date: Mon, 29 Oct 2018 11:58:18 -0600 Subject: [PATCH] Use std::enable_if to enable SFINAE rather than static_assert --- include/boost/integer/extended_euclidean.hpp | 12 ++++-------- test/Jamfile.v2 | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/boost/integer/extended_euclidean.hpp b/include/boost/integer/extended_euclidean.hpp index c3dc50d..966381a 100644 --- a/include/boost/integer/extended_euclidean.hpp +++ b/include/boost/integer/extended_euclidean.hpp @@ -22,16 +22,12 @@ struct euclidean_result_t { Z y; }; +using std::numeric_limits; + template -euclidean_result_t extended_euclidean(Z m, Z n) +euclidean_result_t::is_signed, Z>::type> +extended_euclidean(Z m, Z n) { - using std::numeric_limits; - static_assert(numeric_limits::is_integer, - "The extended Euclidean algorithm works on integral types.\n"); - - static_assert(numeric_limits::is_signed, - "The extended Euclidean algorithm only works on signed integer types.\n"); - if (m < 1 || n < 1) { BOOST_THROW_EXCEPTION(std::domain_error("Arguments must be strictly positive.\n")); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 288ebbc..a0a8dd7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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 ]