source: NonGTP/Boost/boost/numeric/interval/compare/certain.hpp @ 857

Revision 857, 3.4 KB checked in by igarcia, 19 years ago (diff)
Line 
1/* Boost interval/compare/certain.hpp template implementation file
2 *
3 * Copyright 2003 Guillaume Melquiond
4 *
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)
8 */
9
10#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP
11#define BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP
12
13#include <boost/numeric/interval/detail/interval_prototype.hpp>
14#include <boost/numeric/interval/detail/test_input.hpp>
15
16namespace boost {
17namespace numeric {
18namespace interval_lib {
19namespace compare {
20namespace certain {
21
22template<class T, class Policies1, class Policies2> inline
23bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
24{
25  if (detail::test_input(x, y)) throw comparison_error();
26  return x.upper() < y.lower();
27}
28
29template<class T, class Policies> inline
30bool operator<(const interval<T, Policies>& x, const T& y)
31{
32  if (detail::test_input(x, y)) throw comparison_error();
33  return x.upper() < y;
34}
35
36template<class T, class Policies1, class Policies2> inline
37bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
38{
39  if (detail::test_input(x, y)) throw comparison_error();
40  return x.upper() <= y.lower();
41}
42
43template<class T, class Policies> inline
44bool operator<=(const interval<T, Policies>& x, const T& y)
45{
46  if (detail::test_input(x, y)) throw comparison_error();
47  return x.upper() <= y;
48}
49
50template<class T, class Policies1, class Policies2> inline
51bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
52{
53  if (detail::test_input(x, y)) throw comparison_error();
54  return x.lower() > y.upper();
55}
56
57template<class T, class Policies> inline
58bool operator>(const interval<T, Policies>& x, const T& y)
59{
60  if (detail::test_input(x, y)) throw comparison_error();
61  return x.lower() > y;
62}
63
64template<class T, class Policies1, class Policies2> inline
65bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
66{
67  if (detail::test_input(x, y)) throw comparison_error();
68  return x.lower() >= y.upper();
69}
70
71template<class T, class Policies> inline
72bool operator>=(const interval<T, Policies>& x, const T& y)
73{
74  if (detail::test_input(x, y)) throw comparison_error();
75  return x.lower() >= y;
76}
77
78template<class T, class Policies1, class Policies2> inline
79bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
80{
81  if (detail::test_input(x, y)) throw comparison_error();
82  return x.upper() == y.lower() && x.lower() == y.upper();
83}
84
85template<class T, class Policies> inline
86bool operator==(const interval<T, Policies>& x, const T& y)
87{
88  if (detail::test_input(x, y)) throw comparison_error();
89  return x.upper() == y && x.lower() == y;
90}
91
92template<class T, class Policies1, class Policies2> inline
93bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
94{
95  if (detail::test_input(x, y)) throw comparison_error();
96  return x.upper() < y.lower() || x.lower() > y.upper();
97}
98
99template<class T, class Policies> inline
100bool operator!=(const interval<T, Policies>& x, const T& y)
101{
102  if (detail::test_input(x, y)) throw comparison_error();
103  return x.upper() < y || x.lower() > y;
104}
105
106} // namespace certain
107} // namespace compare
108} // namespace interval_lib
109} // namespace numeric
110} // namespace boost
111
112
113#endif // BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP
Note: See TracBrowser for help on using the repository browser.