1 /* Boost interval/compare/possible.hpp template implementation file
3 * Copyright 2003 Guillaume Melquiond
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or
7 * copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP
11 #define BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP
13 #include <boost/numeric/interval/detail/interval_prototype.hpp>
14 #include <boost/numeric/interval/detail/test_input.hpp>
18 namespace interval_lib {
22 template<class T, class Policies1, class Policies2> inline
23 bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
25 if (detail::test_input(x, y)) throw comparison_error();
26 return x.lower() < y.upper();
29 template<class T, class Policies> inline
30 bool operator<(const interval<T, Policies>& x, const T& y)
32 if (detail::test_input(x, y)) throw comparison_error();
36 template<class T, class Policies1, class Policies2> inline
37 bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
39 if (detail::test_input(x, y)) throw comparison_error();
40 return x.lower() <= y.upper();
43 template<class T, class Policies> inline
44 bool operator<=(const interval<T, Policies>& x, const T& y)
46 if (detail::test_input(x, y)) throw comparison_error();
47 return x.lower() <= y;
50 template<class T, class Policies1, class Policies2> inline
51 bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
53 if (detail::test_input(x, y)) throw comparison_error();
54 return x.upper() > y.lower();
57 template<class T, class Policies> inline
58 bool operator>(const interval<T, Policies>& x, const T& y)
60 if (detail::test_input(x, y)) throw comparison_error();
64 template<class T, class Policies1, class Policies2> inline
65 bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
67 if (detail::test_input(x, y)) throw comparison_error();
68 return x.upper() >= y.lower();
71 template<class T, class Policies> inline
72 bool operator>=(const interval<T, Policies>& x, const T& y)
74 if (detail::test_input(x, y)) throw comparison_error();
75 return x.upper() >= y;
78 template<class T, class Policies1, class Policies2> inline
79 bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
81 if (detail::test_input(x, y)) throw comparison_error();
82 return x.lower() <= y.upper() && x.upper() >= y.lower();
85 template<class T, class Policies> inline
86 bool operator==(const interval<T, Policies>& x, const T& y)
88 if (detail::test_input(x, y)) throw comparison_error();
89 return x.lower() <= y && x.upper() >= y;
92 template<class T, class Policies1, class Policies2> inline
93 bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
95 if (detail::test_input(x, y)) throw comparison_error();
96 return x.lower() != y.upper() || x.upper() != y.lower();
99 template<class T, class Policies> inline
100 bool operator!=(const interval<T, Policies>& x, const T& y)
102 if (detail::test_input(x, y)) throw comparison_error();
103 return x.lower() != y || x.upper() != y;
106 } // namespace possible
107 } // namespace compare
108 } // namespace interval_lib
109 } // namespace numeric
113 #endif // BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP