annotate DEPENDENCIES/generic/include/boost/multiprecision/traits/explicit_conversion.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 ///////////////////////////////////////////////////////////////////////////////
Chris@16 2 // Copyright Vicente J. Botet Escriba 2009-2011
Chris@16 3 // Copyright 2012 John Maddock. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #ifndef BOOST_MP_EXPLICIT_CONVERTIBLE_HPP
Chris@16 8 #define BOOST_MP_EXPLICIT_CONVERTIBLE_HPP
Chris@16 9
Chris@16 10 #include <boost/type_traits/is_convertible.hpp>
Chris@16 11 #include <boost/utility/declval.hpp>
Chris@16 12
Chris@16 13
Chris@16 14 namespace boost{ namespace multiprecision{ namespace detail{
Chris@16 15
Chris@16 16 template <int N>
Chris@16 17 struct dummy_size{};
Chris@16 18
Chris@16 19 template<typename S, typename T>
Chris@16 20 struct has_generic_interconversion
Chris@16 21 {
Chris@16 22 typedef typename mpl::if_c<
Chris@16 23 is_number<S>::value && is_number<T>::value,
Chris@16 24 typename mpl::if_c<
Chris@16 25 number_category<S>::value == number_kind_integer,
Chris@16 26 typename mpl::if_c<
Chris@16 27 number_category<T>::value == number_kind_integer
Chris@16 28 || number_category<T>::value == number_kind_floating_point
Chris@16 29 || number_category<T>::value == number_kind_rational
Chris@16 30 || number_category<T>::value == number_kind_fixed_point,
Chris@16 31 mpl::true_,
Chris@16 32 mpl::false_
Chris@16 33 >::type,
Chris@16 34 typename mpl::if_c<
Chris@16 35 number_category<S>::value == number_kind_rational,
Chris@16 36 typename mpl::if_c<
Chris@16 37 number_category<T>::value == number_kind_rational
Chris@16 38 || number_category<T>::value == number_kind_rational,
Chris@16 39 mpl::true_,
Chris@16 40 mpl::false_
Chris@16 41 >::type,
Chris@16 42 typename mpl::if_c<
Chris@16 43 number_category<T>::value == number_kind_floating_point,
Chris@16 44 mpl::true_,
Chris@16 45 mpl::false_
Chris@16 46 >::type
Chris@16 47 >::type
Chris@16 48 >::type,
Chris@16 49 mpl::false_
Chris@16 50 >::type type;
Chris@16 51 };
Chris@16 52
Chris@16 53 template<typename S, typename T>
Chris@16 54 struct is_explicitly_convertible_imp
Chris@16 55 {
Chris@16 56 #ifndef BOOST_NO_SFINAE_EXPR
Chris@16 57 template<typename S1, typename T1>
Chris@16 58 static type_traits::yes_type selector(dummy_size<sizeof(static_cast<T1>(declval<S1>()))>*);
Chris@16 59
Chris@16 60 template<typename S1, typename T1>
Chris@16 61 static type_traits::no_type selector(...);
Chris@16 62
Chris@16 63 static const bool value = sizeof(selector<S,T>(0)) == sizeof(type_traits::yes_type);
Chris@16 64
Chris@16 65 typedef boost::integral_constant<bool,value> type;
Chris@16 66 #else
Chris@16 67 typedef typename has_generic_interconversion<S, T>::type gen_type;
Chris@16 68 typedef mpl::bool_<boost::is_convertible<S, T>::value || gen_type::value> type;
Chris@16 69 #endif
Chris@16 70 };
Chris@16 71
Chris@16 72 template<typename From, typename To>
Chris@16 73 struct is_explicitly_convertible : public is_explicitly_convertible_imp<From, To>::type
Chris@16 74 {
Chris@16 75 };
Chris@16 76
Chris@16 77 }}} // namespaces
Chris@16 78
Chris@16 79 #endif
Chris@16 80