ratio.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // ratio.hpp ---------------------------------------------------------------//
  2. // Copyright 2008 Howard Hinnant
  3. // Copyright 2008 Beman Dawes
  4. // Copyright 2009 Vicente J. Botet Escriba
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See http://www.boost.org/LICENSE_1_0.txt
  7. /*
  8. This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
  9. Many thanks to Howard for making his code available under the Boost license.
  10. The original code was modified to conform to Boost conventions and to section
  11. 20.4 Compile-time rational arithmetic [ratio], of the C++ committee working
  12. paper N2798.
  13. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
  14. time2_demo contained this comment:
  15. Much thanks to Andrei Alexandrescu,
  16. Walter Brown,
  17. Peter Dimov,
  18. Jeff Garland,
  19. Terry Golubiewski,
  20. Daniel Krugler,
  21. Anthony Williams.
  22. */
  23. // The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
  24. #ifndef BOOST_RATIO_RATIO_HPP
  25. #define BOOST_RATIO_RATIO_HPP
  26. #include <boost/ratio/ratio_fwd.hpp>
  27. #include <boost/ratio/detail/gcd_lcm.hpp>
  28. namespace boost
  29. {
  30. // extension used by Chrono
  31. template <class R1, class R2> using ratio_gcd = typename ratio<
  32. ratio_detail::gcd<R1::num, R2::num>::value,
  33. ratio_detail::lcm<R1::den, R2::den>::value>::type;
  34. } // namespace boost
  35. #endif // BOOST_RATIO_RATIO_HPP