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.
This commit is contained in:
jzmaddock
2017-12-25 18:07:48 +00:00
parent 017f652ce3
commit 4daa1baf6d
2 changed files with 6 additions and 1 deletions

View File

@@ -628,8 +628,12 @@ public:
return this->template convert_to<T>();
}
# else
#if BOOST_WORKAROUND(BOOST_MSVC, < 1900)
template <class T>
explicit operator T()const
#else
template <class T, class = typename boost::disable_if_c<boost::is_constructible<T, self_type const&>::value || !boost::is_default_constructible<T>::value, T>::type>
#endif
explicit operator T ()const
{
return this->template convert_to<T>();
}

View File

@@ -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 : <define>TEST_FLOAT128 <source>quadmath : ]
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]