rational.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2009: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. /*------------------------------------------------------------------------------
  9. itl_rational provides adapter code for boost::rational.
  10. ------------------------------------------------------------------------------*/
  11. #ifndef BOOST_ICL_RATIONAL_HPP_JOFA_080913
  12. #define BOOST_ICL_RATIONAL_HPP_JOFA_080913
  13. #include <boost/config.hpp> // For BOOST_MSVC and more
  14. #ifdef BOOST_MSVC
  15. #pragma warning(push)
  16. #pragma warning(disable:4127) // conditional expression is constant
  17. #pragma warning(disable:4512) // 'boost::detail::resetter' : assignment operator could not be generated
  18. #pragma warning(disable:4800) // 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)
  19. #endif
  20. #include <boost/rational.hpp>
  21. #ifdef BOOST_MSVC
  22. #pragma warning(pop)
  23. #endif
  24. #include <boost/icl/type_traits/is_continuous.hpp>
  25. #include <boost/icl/type_traits/has_inverse.hpp>
  26. #include <boost/icl/type_traits/is_numeric.hpp>
  27. namespace boost{namespace icl
  28. {
  29. template<class Integral>
  30. struct is_numeric<boost::rational<Integral> >
  31. {
  32. typedef is_numeric type;
  33. BOOST_STATIC_CONSTANT(bool, value = true);
  34. };
  35. template<class Integral>
  36. struct is_continuous<boost::rational<Integral> >
  37. {
  38. typedef is_continuous type;
  39. BOOST_STATIC_CONSTANT(bool, value = true);
  40. };
  41. template<class Integral>
  42. struct is_discrete<boost::rational<Integral> >
  43. {
  44. typedef is_discrete type;
  45. BOOST_STATIC_CONSTANT(bool, value = false);
  46. };
  47. template<class Integral>
  48. struct has_inverse<boost::rational<Integral> >
  49. {
  50. typedef has_inverse type;
  51. BOOST_STATIC_CONSTANT(bool, value = (boost::is_signed<Integral>::value));
  52. };
  53. }} // namespace icl boost
  54. #endif