]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/interval/include/boost/numeric/interval/compare/lexicographic.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / numeric / interval / include / boost / numeric / interval / compare / lexicographic.hpp
1 /* Boost interval/compare/lexicographic.hpp template implementation file
2 *
3 * Copyright 2002-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_LEXICOGRAPHIC_HPP
11 #define BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP
12
13 #include <boost/numeric/interval/detail/interval_prototype.hpp>
14 #include <boost/numeric/interval/detail/test_input.hpp>
15
16 namespace boost {
17 namespace numeric {
18 namespace interval_lib {
19 namespace compare {
20 namespace lexicographic {
21
22 template<class T, class Policies1, class Policies2> inline
23 bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
24 {
25 if (detail::test_input(x, y)) throw comparison_error();
26 const T& xl = x.lower();
27 const T& yl = y.lower();
28 return xl < yl || (xl == yl && x.upper() < y.upper());
29 }
30
31 template<class T, class Policies> inline
32 bool operator<(const interval<T, Policies>& x, const T& y)
33 {
34 if (detail::test_input(x, y)) throw comparison_error();
35 return x.lower() < y;
36 }
37
38 template<class T, class Policies1, class Policies2> inline
39 bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
40 {
41 if (detail::test_input(x, y)) throw comparison_error();
42 const T& xl = x.lower();
43 const T& yl = y.lower();
44 return xl < yl || (xl == yl && x.upper() <= y.upper());
45 }
46
47 template<class T, class Policies> inline
48 bool operator<=(const interval<T, Policies>& x, const T& y)
49 {
50 if (detail::test_input(x, y)) throw comparison_error();
51 const T& xl = x.lower();
52 return xl < y || (xl == y && x.upper() <= y);
53 }
54
55 template<class T, class Policies1, class Policies2> inline
56 bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
57 {
58 if (detail::test_input(x, y)) throw comparison_error();
59 const T& xl = x.lower();
60 const T& yl = y.lower();
61 return xl > yl || (xl == yl && x.upper() > y.upper());
62 }
63
64 template<class T, class Policies> inline
65 bool operator>(const interval<T, Policies>& x, const T& y)
66 {
67 if (detail::test_input(x, y)) throw comparison_error();
68 const T& xl = x.lower();
69 return xl > y || (xl == y && x.upper() > y);
70 }
71
72 template<class T, class Policies1, class Policies2> inline
73 bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
74 {
75 if (detail::test_input(x, y)) throw comparison_error();
76 const T& xl = x.lower();
77 const T& yl = y.lower();
78 return xl > yl || (xl == yl && x.upper() >= y.upper());
79 }
80
81 template<class T, class Policies> inline
82 bool operator>=(const interval<T, Policies>& x, const T& y)
83 {
84 if (detail::test_input(x, y)) throw comparison_error();
85 return x.lower() >= y;
86 }
87
88 template<class T, class Policies1, class Policies2> inline
89 bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
90 {
91 if (detail::test_input(x, y)) throw comparison_error();
92 return x.lower() == y.lower() && x.upper() == y.upper();
93 }
94
95 template<class T, class Policies> inline
96 bool operator==(const interval<T, Policies>& x, const T& y)
97 {
98 if (detail::test_input(x, y)) throw comparison_error();
99 return x.lower() == y && x.upper() == y;
100 }
101
102 template<class T, class Policies1, class Policies2> inline
103 bool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
104 {
105 if (detail::test_input(x, y)) throw comparison_error();
106 return x.lower() != y.lower() || x.upper() != y.upper();
107 }
108
109 template<class T, class Policies> inline
110 bool operator!=(const interval<T, Policies>& x, const T& y)
111 {
112 if (detail::test_input(x, y)) throw comparison_error();
113 return x.lower() != y || x.upper() != y;
114 }
115
116 } // namespace lexicographic
117 } // namespace compare
118 } // namespace interval_lib
119 } // namespace numeric
120 } // namespace boost
121
122 #endif // BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP