Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:24

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //  Copyright Vicente J. Botet Escriba 2009-2011
0003 //  Copyright 2012 John Maddock. Distributed under the Boost
0004 //  Software License, Version 1.0. (See accompanying file
0005 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_MP_EXPLICIT_CONVERSION_HPP
0008 #define BOOST_MP_EXPLICIT_CONVERSION_HPP
0009 
0010 #include <type_traits>
0011 #include <boost/multiprecision/detail/standalone_config.hpp>
0012 #include <boost/multiprecision/detail/number_base.hpp> // number_category
0013 
0014 namespace boost {
0015 namespace multiprecision {
0016 namespace detail {
0017 
0018 template <unsigned int N>
0019 struct dummy_size
0020 {};
0021 
0022 template <typename S, typename T>
0023 struct has_generic_interconversion
0024 {
0025    using type = typename std::conditional<
0026        is_number<S>::value && is_number<T>::value,
0027        typename std::conditional<
0028            number_category<S>::value == number_kind_integer,
0029            typename std::conditional<
0030                number_category<T>::value == number_kind_integer || number_category<T>::value == number_kind_floating_point || number_category<T>::value == number_kind_rational || number_category<T>::value == number_kind_fixed_point,
0031                std::true_type,
0032                std::false_type >::type,
0033            typename std::conditional<
0034                number_category<S>::value == number_kind_rational,
0035                typename std::conditional<
0036                    number_category<T>::value == number_kind_rational || number_category<T>::value == number_kind_rational,
0037                    std::true_type,
0038                    std::false_type >::type,
0039                typename std::conditional<
0040                    number_category<T>::value == number_kind_floating_point,
0041                    std::true_type,
0042                    std::false_type >::type>::type>::type,
0043        std::false_type >::type;
0044 };
0045 
0046 template <typename S, typename T>
0047 struct is_explicitly_convertible_imp
0048 {
0049    template <typename S1, typename T1>
0050    static int selector(dummy_size<static_cast<unsigned int>(sizeof(new T1(std::declval<S1>())))>*);
0051 
0052    template <typename S1, typename T1>
0053    static char selector(...);
0054 
0055    static constexpr bool value = sizeof(selector<S, T>(nullptr)) == sizeof(int);
0056 
0057    using type = std::integral_constant<bool, value>;
0058 };
0059 
0060 template <typename From, typename To>
0061 struct is_explicitly_convertible : public is_explicitly_convertible_imp<From, To>::type
0062 {
0063 };
0064 
0065 }}} // namespace boost::multiprecision::detail
0066 
0067 #endif