is_evenly_divisible_by.hpp 845 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef BOOST_RATIO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
  2. #define BOOST_RATIO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP
  3. // Copyright 2023 Peter Dimov
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #include <type_traits>
  7. #include <cstdint>
  8. namespace boost
  9. {
  10. namespace ratio_detail
  11. {
  12. template<std::intmax_t A, std::intmax_t B> struct is_evenly_divisible_by_: std::integral_constant<bool, A % B == 0>
  13. {
  14. };
  15. template<std::intmax_t A> struct is_evenly_divisible_by_<A, 0>: std::false_type
  16. {
  17. };
  18. template<class R1, class R2> struct is_evenly_divisible_by: std::integral_constant<bool,
  19. is_evenly_divisible_by_<R1::num, R2::num>::value && is_evenly_divisible_by_<R2::den, R1::den>::value>
  20. {
  21. };
  22. } // namespace ratio_detail
  23. } // namespace boost
  24. #endif // BOOST_RATIO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP