/////////////////////////////////////////////////////////////////////////////// // Copyright Vicente J. Botet Escriba 2009-2011 // Copyright 2012 John Maddock. Distributed under 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) #ifndef BOOST_MP_EXPLICIT_CONVERTIBLE_HPP #define BOOST_MP_EXPLICIT_CONVERTIBLE_HPP #include #include #include #include #include #include // number_category namespace boost { namespace multiprecision { namespace detail { template struct dummy_size {}; template struct has_generic_interconversion { typedef typename boost::conditional< is_number::value && is_number::value, typename boost::conditional< number_category::value == number_kind_integer, typename boost::conditional< number_category::value == number_kind_integer || number_category::value == number_kind_floating_point || number_category::value == number_kind_rational || number_category::value == number_kind_fixed_point, boost::true_type, boost::false_type>::type, typename boost::conditional< number_category::value == number_kind_rational, typename boost::conditional< number_category::value == number_kind_rational || number_category::value == number_kind_rational, boost::true_type, boost::false_type>::type, typename boost::conditional< number_category::value == number_kind_floating_point, boost::true_type, boost::false_type>::type>::type>::type, boost::false_type>::type type; }; template struct is_explicitly_convertible_imp { #ifndef BOOST_NO_SFINAE_EXPR template static type_traits::yes_type selector(dummy_size()))>*); template static type_traits::no_type selector(...); static const bool value = sizeof(selector(0)) == sizeof(type_traits::yes_type); typedef boost::integral_constant type; #else typedef typename has_generic_interconversion::type gen_type; typedef boost::integral_constant::value || gen_type::value> type; #endif }; template struct is_explicitly_convertible : public is_explicitly_convertible_imp::type { }; #ifdef BOOST_NO_SFINAE_EXPR template struct is_explicitly_convertible, number > : public is_explicitly_convertible { }; #endif }}} // namespace boost::multiprecision::detail #endif