1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright Vicente J. Botet Escriba 2009-2011
3 // Copyright 2012 John Maddock. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_MP_RESTRICTED_CONVERSION_HPP
8 #define BOOST_MP_RESTRICTED_CONVERSION_HPP
10 #include <boost/multiprecision/traits/explicit_conversion.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/multiprecision/detail/number_base.hpp>
14 namespace boost{ namespace multiprecision{ namespace detail{
17 template <class From, class To>
18 struct is_lossy_conversion
20 typedef typename mpl::if_c<
21 ((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_integer))
22 /* || ((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_rational))*/
23 || ((number_category<From>::value == number_kind_rational) && (number_category<To>::value == number_kind_integer))
24 || ((number_category<From>::value == number_kind_fixed_point) && (number_category<To>::value == number_kind_integer))
25 || (number_category<From>::value == number_kind_unknown)
26 || (number_category<To>::value == number_kind_unknown),
30 static const bool value = type::value;
33 template<typename From, typename To>
34 struct is_restricted_conversion
36 typedef typename mpl::if_c<
37 ((is_explicitly_convertible<From, To>::value && !is_convertible<From, To>::value)
38 || is_lossy_conversion<From, To>::value),
42 static const bool value = type::value;
47 #endif // BOOST_MP_RESTRICTED_CONVERSION_HPP