From 4daa1baf6d5eaaf16bfc6294e1ac3dd0e051de3f Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 25 Dec 2017 18:07:48 +0000 Subject: [PATCH] Multiprecision: disable explicit conversion operator if the target type is already constructible from *this. Prevents ambiguity between the target types constructor and the conversion operator. See https://github.com/boostorg/multiprecision/issues/30. --- include/boost/multiprecision/number.hpp | 6 +++++- test/Jamfile.v2 | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index dc61d696..f99ef2a9 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -628,8 +628,12 @@ public: return this->template convert_to(); } # else +#if BOOST_WORKAROUND(BOOST_MSVC, < 1900) template - explicit operator T()const +#else + template ::value || !boost::is_default_constructible::value, T>::type> +#endif + explicit operator T ()const { return this->template convert_to(); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 45e07b9d..c4561d4b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -863,6 +863,7 @@ run test_float_conversions.cpp no_eh_support ; # compile bug11922.cpp ; run bug12039.cpp no_eh_support ; +compile git_issue_30.cpp ; run test_hash.cpp : : : [ check-target-builds ../config//has_float128 : TEST_FLOAT128 quadmath : ] [ check-target-builds ../config//has_gmp : TEST_GMP gmp : ]