]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/multiprecision/traits/is_backend.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / multiprecision / traits / is_backend.hpp
CommitLineData
7c673cae
FG
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)
5
6#ifndef BOOST_MP_IS_BACKEND_HPP
7#define BOOST_MP_IS_BACKEND_HPP
8
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>
13
92f5a8d4
TL
14namespace boost { namespace multiprecision { namespace detail {
15
16BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types)
17BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types)
18BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types)
19
20template <class T>
21struct is_backend
22{
23 static const bool value = has_signed_types<T>::value && has_unsigned_types<T>::value && has_float_types<T>::value;
24};
25
26template <class Backend>
27struct other_backend
28{
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;
32};
33
34template <class B, class V>
35struct number_from_backend
36{
37 typedef typename boost::conditional<
38 boost::is_convertible<V, number<B> >::value,
39 number<B>,
40 typename other_backend<B>::type>::type type;
41};
42
43template <bool b, class T, class U>
44struct is_first_backend_imp
45{
46 static const bool value = false;
47};
48template <class T, class U>
49struct is_first_backend_imp<true, T, U>
50{
51 static const bool value = is_convertible<U, number<T, et_on> >::value || is_convertible<U, number<T, et_off> >::value;
52};
53
54template <class T, class U>
55struct is_first_backend : is_first_backend_imp<is_backend<T>::value, T, U>
56{};
57
58template <bool b, class T, class U>
59struct is_second_backend_imp
60{
61 static const bool value = false;
62};
63template <class T, class U>
64struct is_second_backend_imp<true, T, U>
65{
66 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;
67};
68
69template <class T, class U>
70struct is_second_backend : is_second_backend_imp<is_backend<U>::value, T, U>
71{};
7c673cae
FG
72
73}
74}
92f5a8d4 75} // namespace boost::multiprecision::detail
7c673cae
FG
76
77#endif // BOOST_MP_IS_BACKEND_HPP