summaryrefslogtreecommitdiff
path: root/boost/multiprecision/traits/is_backend.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:30:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:32:57 +0900
commit71d216b90256936a9638f325af9bc69d720e75de (patch)
tree9c5f682d341c7c88ad0c8e3d4b262e00b6fb691a /boost/multiprecision/traits/is_backend.hpp
parent733b5d5ae2c5d625211e2985ac25728ac3f54883 (diff)
downloadboost-71d216b90256936a9638f325af9bc69d720e75de.tar.gz
boost-71d216b90256936a9638f325af9bc69d720e75de.tar.bz2
boost-71d216b90256936a9638f325af9bc69d720e75de.zip
Imported Upstream version 1.59.0
Change-Id: I2dde00f4eca71df3eea9d251dcaecde18a6c90a5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/multiprecision/traits/is_backend.hpp')
-rw-r--r--boost/multiprecision/traits/is_backend.hpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/boost/multiprecision/traits/is_backend.hpp b/boost/multiprecision/traits/is_backend.hpp
new file mode 100644
index 0000000000..9b23c86665
--- /dev/null
+++ b/boost/multiprecision/traits/is_backend.hpp
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2015 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_MP_IS_BACKEND_HPP
+#define BOOST_MP_IS_BACKEND_HPP
+
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/type_traits/conditional.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/multiprecision/detail/number_base.hpp>
+
+namespace boost{ namespace multiprecision{ namespace detail{
+
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types);
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types);
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types);
+
+ template <class T>
+ struct is_backend
+ {
+ static const bool value = has_signed_types<T>::value && has_unsigned_types<T>::value && has_float_types<T>::value;
+ };
+
+ template <class Backend>
+ struct other_backend
+ {
+ typedef typename boost::conditional<
+ boost::is_same<number<Backend>, number<Backend, et_on> >::value,
+ number<Backend, et_off>, number<Backend, et_on> >::type type;
+ };
+
+ template <class B, class V>
+ struct number_from_backend
+ {
+ typedef typename boost::conditional <
+ boost::is_convertible<V, number<B> >::value,
+ number<B>,
+ typename other_backend<B>::type > ::type type;
+ };
+
+ template <bool b, class T, class U>
+ struct is_first_backend_imp{ static const bool value = false; };
+ template <class T, class U>
+ 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; };
+
+ template <class T, class U>
+ struct is_first_backend : is_first_backend_imp<is_backend<T>::value, T, U> {};
+
+ template <bool b, class T, class U>
+ struct is_second_backend_imp{ static const bool value = false; };
+ template <class T, class U>
+ 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; };
+
+ template <class T, class U>
+ struct is_second_backend : is_second_backend_imp<is_backend<U>::value, T, U> {};
+
+}
+}
+}
+
+#endif // BOOST_MP_IS_BACKEND_HPP