File indexing completed on 2025-01-18 09:42:22
0001
0002
0003
0004
0005
0006 #ifndef BOOST_MP_MIN_MAX_HPP
0007 #define BOOST_MP_MIN_MAX_HPP
0008
0009 #include <boost/multiprecision/traits/is_backend.hpp>
0010
0011 namespace boost { namespace multiprecision {
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 template <class Backend>
0029 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on>&>::type(min)(const number<Backend, et_on>& a, const number<Backend, et_on>& b)
0030 {
0031 return a < b ? a : b;
0032 }
0033 template <class Backend, class tag, class A1, class A2, class A3, class A4>
0034 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on> >::type(min)(const number<Backend, et_on>& a, const detail::expression<tag, A1, A2, A3, A4>& b)
0035 {
0036 number<Backend, et_on> t(b);
0037 if (a < t)
0038 return a;
0039 return std::move(t);
0040 }
0041 template <class tag, class A1, class A2, class A3, class A4, class Backend>
0042 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on> >::type(min)(const detail::expression<tag, A1, A2, A3, A4>& a, const number<Backend, et_on>& b)
0043 {
0044 number<Backend, et_on> t(a);
0045 if (t < b)
0046 return std::move(t);
0047 return b;
0048 }
0049 template <class tag, class A1, class A2, class A3, class A4, class tagb, class A1b, class A2b, class A3b, class A4b>
0050 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type(min)(const detail::expression<tag, A1, A2, A3, A4>& a, const detail::expression<tagb, A1b, A2b, A3b, A4b>& b)
0051 {
0052 typename detail::expression<tag, A1, A2, A3, A4>::result_type t1(a), t2(b);
0053 if (t1 < t2)
0054 return std::move(t1);
0055 return std::move(t2);
0056 }
0057 template <class tag, class A1, class A2, class A3, class A4>
0058 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type(min)(const detail::expression<tag, A1, A2, A3, A4>& a, const detail::expression<tag, A1, A2, A3, A4>& b)
0059 {
0060 typename detail::expression<tag, A1, A2, A3, A4>::result_type t1(a), t2(b);
0061 if (t1 < t2)
0062 return std::move(t1);
0063 return std::move(t2);
0064 }
0065
0066 template <class Backend>
0067 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on>&>::type(max)(const number<Backend, et_on>& a, const number<Backend, et_on>& b)
0068 {
0069 return a > b ? a : b;
0070 }
0071 template <class Backend, class tag, class A1, class A2, class A3, class A4>
0072 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on> >::type(max)(const number<Backend, et_on>& a, const detail::expression<tag, A1, A2, A3, A4>& b)
0073 {
0074 number<Backend, et_on> t(b);
0075 if (a > t)
0076 return a;
0077 return std::move(t);
0078 }
0079 template <class tag, class A1, class A2, class A3, class A4, class Backend>
0080 inline typename std::enable_if<boost::multiprecision::detail::is_backend<Backend>::value, const number<Backend, et_on> >::type(max)(const detail::expression<tag, A1, A2, A3, A4>& a, const number<Backend, et_on>& b)
0081 {
0082 number<Backend, et_on> t(a);
0083 if (t > b)
0084 return std::move(t);
0085 return b;
0086 }
0087 template <class tag, class A1, class A2, class A3, class A4, class tagb, class A1b, class A2b, class A3b, class A4b>
0088 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type(max)(const detail::expression<tag, A1, A2, A3, A4>& a, const detail::expression<tagb, A1b, A2b, A3b, A4b>& b)
0089 {
0090 typename detail::expression<tag, A1, A2, A3, A4>::result_type t1(a), t2(b);
0091 if (t1 > t2)
0092 return std::move(t1);
0093 return std::move(t2);
0094 }
0095 template <class tag, class A1, class A2, class A3, class A4>
0096 inline typename detail::expression<tag, A1, A2, A3, A4>::result_type(max)(const detail::expression<tag, A1, A2, A3, A4>& a, const detail::expression<tag, A1, A2, A3, A4>& b)
0097 {
0098 typename detail::expression<tag, A1, A2, A3, A4>::result_type t1(a), t2(b);
0099 if (t1 > t2)
0100 return std::move(t1);
0101 return std::move(t2);
0102 }
0103
0104 }}
0105
0106 #endif