certain.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #ifndef BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP
  10. #define BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP
  11. #include <boost/numeric/interval/detail/interval_prototype.hpp>
  12. #include <boost/numeric/interval/detail/test_input.hpp>
  13. namespace boost {
  14. namespace numeric {
  15. namespace interval_lib {
  16. namespace compare {
  17. namespace certain {
  18. template<class T, class Policies1, class Policies2> inline
  19. bool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
  20. {
  21. if (detail::test_input(x, y)) throw comparison_error();
  22. return x.upper() < y.lower();
  23. }
  24. template<class T, class Policies> inline
  25. bool operator<(const interval<T, Policies>& x, const T& y)
  26. {
  27. if (detail::test_input(x, y)) throw comparison_error();
  28. return x.upper() < y;
  29. }
  30. template<class T, class Policies1, class Policies2> inline
  31. bool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
  32. {
  33. if (detail::test_input(x, y)) throw comparison_error();
  34. return x.upper() <= y.lower();
  35. }
  36. template<class T, class Policies> inline
  37. bool operator<=(const interval<T, Policies>& x, const T& y)
  38. {
  39. if (detail::test_input(x, y)) throw comparison_error();
  40. return x.upper() <= y;
  41. }
  42. template<class T, class Policies1, class Policies2> inline
  43. bool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
  44. {
  45. if (detail::test_input(x, y)) throw comparison_error();
  46. return x.lower() > y.upper();
  47. }
  48. template<class T, class Policies> inline
  49. bool operator>(const interval<T, Policies>& x, const T& y)
  50. {
  51. if (detail::test_input(x, y)) throw comparison_error();
  52. return x.lower() > y;
  53. }
  54. template<class T, class Policies1, class Policies2> inline
  55. bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
  56. {
  57. if (detail::test_input(x, y)) throw comparison_error();
  58. return x.lower() >= y.upper();
  59. }
  60. template<class T, class Policies> inline
  61. bool operator>=(const interval<T, Policies>& x, const T& y)
  62. {
  63. if (detail::test_input(x, y)) throw comparison_error();
  64. return x.lower() >= y;
  65. }
  66. template<class T, class Policies1, class Policies2> inline
  67. bool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
  68. {
  69. if (detail::test_input(x, y)) throw comparison_error();
  70. return x.upper() == y.lower() && x.lower() == y.upper();
  71. }
  72. template<class T, class Policies> inline
  73. bool operator==(const interval<T, Policies>& x, const T& y)
  74. {
  75. if (detail::test_input(x, y)) throw comparison_error();
  76. return x.upper() == y && x.lower() == y;
  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. template<class T, class Policies> inline
  85. bool operator!=(const interval<T, Policies>& x, const T& y)
  86. {
  87. if (detail::test_input(x, y)) throw comparison_error();
  88. return x.upper() < y || x.lower() > y;
  89. }
  90. } // namespace certain
  91. } // namespace compare
  92. } // namespace interval_lib
  93. } // namespace numeric
  94. } // namespace boost
  95. #endif // BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP