1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2015 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_MP_IS_BACKEND_HPP
7 #define BOOST_MP_IS_BACKEND_HPP
9 #include <boost/mpl/has_xxx.hpp>
10 #include <boost/type_traits/conditional.hpp>
11 #include <boost/type_traits/is_convertible.hpp>
12 #include <boost/multiprecision/detail/number_base.hpp>
14 namespace boost{ namespace multiprecision{ namespace detail{
16 BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types);
17 BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types);
18 BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types);
23 static const bool value = has_signed_types<T>::value && has_unsigned_types<T>::value && has_float_types<T>::value;
26 template <class Backend>
29 typedef typename boost::conditional<
30 boost::is_same<number<Backend>, number<Backend, et_on> >::value,
31 number<Backend, et_off>, number<Backend, et_on> >::type type;
34 template <class B, class V>
35 struct number_from_backend
37 typedef typename boost::conditional <
38 boost::is_convertible<V, number<B> >::value,
40 typename other_backend<B>::type > ::type type;
43 template <bool b, class T, class U>
44 struct is_first_backend_imp{ static const bool value = false; };
45 template <class T, class U>
46 struct is_first_backend_imp<true, T, U>{ static const bool value = is_convertible<U, number<T, et_on> >::value || is_convertible<U, number<T, et_off> >::value; };
48 template <class T, class U>
49 struct is_first_backend : is_first_backend_imp<is_backend<T>::value, T, U> {};
51 template <bool b, class T, class U>
52 struct is_second_backend_imp{ static const bool value = false; };
53 template <class T, class U>
54 struct is_second_backend_imp<true, T, U>{ static const bool value = (is_convertible<T, number<U, et_on> >::value || is_convertible<T, number<U, et_off> >::value) && !is_first_backend<T, U>::value; };
56 template <class T, class U>
57 struct is_second_backend : is_second_backend_imp<is_backend<U>::value, T, U> {};
63 #endif // BOOST_MP_IS_BACKEND_HPP