/////////////////////////////////////////////////////////////////////////////// // Copyright 2015 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_IS_BACKEND_HPP #define BOOST_MP_IS_BACKEND_HPP #include namespace boost { namespace multiprecision { namespace detail { template struct has_signed_types { template static double check(U*, typename U::signed_types* = 0); static char check(...); static T* get(); static constexpr bool value = sizeof(check(get())) == sizeof(double); }; template struct has_unsigned_types { template static double check(U*, typename U::unsigned_types* = 0); static char check(...); static T* get(); static constexpr bool value = sizeof(check(get())) == sizeof(double); }; template struct has_float_types { template static double check(U*, typename U::float_types* = 0); static char check(...); static T* get(); static constexpr bool value = sizeof(check(get())) == sizeof(double); }; template struct is_backend { static constexpr const bool value = has_signed_types::value && has_unsigned_types::value && has_float_types::value; }; template struct other_backend { using type = typename std::conditional< std::is_same, number >::value, number, number >::type; }; template struct number_from_backend { using type = typename std::conditional< std::is_convertible >::value, number, typename other_backend::type>::type; }; template struct is_first_backend_imp { static constexpr const bool value = false; }; template struct is_first_backend_imp { static constexpr const bool value = std::is_convertible >::value || std::is_convertible >::value; }; template struct is_first_backend : is_first_backend_imp::value, T, U> {}; template struct is_second_backend_imp { static constexpr const bool value = false; }; template struct is_second_backend_imp { static constexpr const bool value = (std::is_convertible >::value || std::is_convertible >::value) && !is_first_backend::value; }; template struct is_second_backend : is_second_backend_imp::value, T, U> {}; } } } // namespace boost::multiprecision::detail #endif // BOOST_MP_IS_BACKEND_HPP