Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // Copyright Vicente J. Botet Escriba 2009-2011 Chris@16: // Copyright 2012 John Maddock. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_MP_EXPLICIT_CONVERTIBLE_HPP Chris@16: #define BOOST_MP_EXPLICIT_CONVERTIBLE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost{ namespace multiprecision{ namespace detail{ Chris@16: Chris@16: template Chris@16: struct dummy_size{}; Chris@16: Chris@16: template Chris@16: struct has_generic_interconversion Chris@16: { Chris@16: typedef typename mpl::if_c< Chris@16: is_number::value && is_number::value, Chris@16: typename mpl::if_c< Chris@16: number_category::value == number_kind_integer, Chris@16: typename mpl::if_c< Chris@16: number_category::value == number_kind_integer Chris@16: || number_category::value == number_kind_floating_point Chris@16: || number_category::value == number_kind_rational Chris@16: || number_category::value == number_kind_fixed_point, Chris@16: mpl::true_, Chris@16: mpl::false_ Chris@16: >::type, Chris@16: typename mpl::if_c< Chris@16: number_category::value == number_kind_rational, Chris@16: typename mpl::if_c< Chris@16: number_category::value == number_kind_rational Chris@16: || number_category::value == number_kind_rational, Chris@16: mpl::true_, Chris@16: mpl::false_ Chris@16: >::type, Chris@16: typename mpl::if_c< Chris@16: number_category::value == number_kind_floating_point, Chris@16: mpl::true_, Chris@16: mpl::false_ Chris@16: >::type Chris@16: >::type Chris@16: >::type, Chris@16: mpl::false_ Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_explicitly_convertible_imp Chris@16: { Chris@16: #ifndef BOOST_NO_SFINAE_EXPR Chris@16: template Chris@16: static type_traits::yes_type selector(dummy_size(declval()))>*); Chris@16: Chris@16: template Chris@16: static type_traits::no_type selector(...); Chris@16: Chris@16: static const bool value = sizeof(selector(0)) == sizeof(type_traits::yes_type); Chris@16: Chris@16: typedef boost::integral_constant type; Chris@16: #else Chris@16: typedef typename has_generic_interconversion::type gen_type; Chris@16: typedef mpl::bool_::value || gen_type::value> type; Chris@16: #endif Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_explicitly_convertible : public is_explicitly_convertible_imp::type Chris@16: { Chris@16: }; Chris@16: Chris@16: }}} // namespaces Chris@16: Chris@16: #endif Chris@16: