]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/include/boost/multiprecision/traits/is_restricted_conversion.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / multiprecision / include / boost / multiprecision / traits / is_restricted_conversion.hpp
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)
6
7 #ifndef BOOST_MP_RESTRICTED_CONVERSION_HPP
8 #define BOOST_MP_RESTRICTED_CONVERSION_HPP
9
10 #include <boost/multiprecision/traits/explicit_conversion.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/multiprecision/detail/number_base.hpp>
13
14 namespace boost{ namespace multiprecision{ namespace detail{
15
16
17 template <class From, class To>
18 struct is_lossy_conversion
19 {
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),
27 mpl::true_,
28 mpl::false_
29 >::type type;
30 static const bool value = type::value;
31 };
32
33 template<typename From, typename To>
34 struct is_restricted_conversion
35 {
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),
39 mpl::true_,
40 mpl::false_
41 >::type type;
42 static const bool value = type::value;
43 };
44
45 }}} // namespaces
46
47 #endif // BOOST_MP_RESTRICTED_CONVERSION_HPP
48