[857] | 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 |
|
---|
| 16 | namespace boost {
|
---|
| 17 | namespace numeric {
|
---|
| 18 | namespace interval_lib {
|
---|
| 19 | namespace compare {
|
---|
| 20 | namespace certain {
|
---|
| 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 | return x.upper() < y.lower();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | template<class T, class Policies> inline
|
---|
| 30 | bool 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 |
|
---|
| 36 | template<class T, class Policies1, class Policies2> inline
|
---|
| 37 | bool 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 |
|
---|
| 43 | template<class T, class Policies> inline
|
---|
| 44 | bool 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 |
|
---|
| 50 | template<class T, class Policies1, class Policies2> inline
|
---|
| 51 | bool 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 |
|
---|
| 57 | template<class T, class Policies> inline
|
---|
| 58 | bool 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 |
|
---|
| 64 | template<class T, class Policies1, class Policies2> inline
|
---|
| 65 | bool 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 |
|
---|
| 71 | template<class T, class Policies> inline
|
---|
| 72 | bool 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 |
|
---|
| 78 | template<class T, class Policies1, class Policies2> inline
|
---|
| 79 | bool 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 |
|
---|
| 85 | template<class T, class Policies> inline
|
---|
| 86 | bool 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 |
|
---|
| 92 | template<class T, class Policies1, class Policies2> inline
|
---|
| 93 | bool 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 |
|
---|
| 99 | template<class T, class Policies> inline
|
---|
| 100 | bool 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
|
---|