integer.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Boost interval/ext/integer.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_EXT_INTEGER_HPP
  10. #define BOOST_NUMERIC_INTERVAL_EXT_INTEGER_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. template<class T, class Policies> inline
  16. interval<T, Policies> operator+ (const interval<T, Policies>& x, int y)
  17. {
  18. return x + static_cast<T>(y);
  19. }
  20. template<class T, class Policies> inline
  21. interval<T, Policies> operator+ (int x, const interval<T, Policies>& y)
  22. {
  23. return static_cast<T>(x) + y;
  24. }
  25. template<class T, class Policies> inline
  26. interval<T, Policies> operator- (const interval<T, Policies>& x, int y)
  27. {
  28. return x - static_cast<T>(y);
  29. }
  30. template<class T, class Policies> inline
  31. interval<T, Policies> operator- (int x, const interval<T, Policies>& y)
  32. {
  33. return static_cast<T>(x) - y;
  34. }
  35. template<class T, class Policies> inline
  36. interval<T, Policies> operator* (const interval<T, Policies>& x, int y)
  37. {
  38. return x * static_cast<T>(y);
  39. }
  40. template<class T, class Policies> inline
  41. interval<T, Policies> operator* (int x, const interval<T, Policies>& y)
  42. {
  43. return static_cast<T>(x) * y;
  44. }
  45. template<class T, class Policies> inline
  46. interval<T, Policies> operator/ (const interval<T, Policies>& x, int y)
  47. {
  48. return x / static_cast<T>(y);
  49. }
  50. template<class T, class Policies> inline
  51. interval<T, Policies> operator/ (int x, const interval<T, Policies>& y)
  52. {
  53. return static_cast<T>(x) / y;
  54. }
  55. } // namespace numeric
  56. } // namespace boost
  57. #endif // BOOST_NUMERIC_INTERVAL_EXT_INTEGER_HPP