Files
cppdraft_translate/cppdraft/ratio/comparison.md
2025-10-25 03:02:53 +03:00

56 lines
1.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[ratio.comparison]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.5 Compile-time rational arithmetic [[ratio]](ratio#comparison)
### 21.5.5 Comparison of ratios [ratio.comparison]
[🔗](#lib:ratio_equal)
`template<class R1, class R2>
struct ratio_equal : bool_constant<R1::num == R2::num && R1::den == R2::den> { };
`
[🔗](#lib:ratio_not_equal)
`template<class R1, class R2>
struct ratio_not_equal : bool_constant<!ratio_equal_v<R1, R2>> { };
`
[🔗](#lib:ratio_less)
`template<class R1, class R2>
struct ratio_less : bool_constant<see below> { };
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L7242)
If R1::num × R2::den is less than R2::num × R1::den,ratio_less<R1, R2> shall be
derived from bool_constant<true>; otherwise it shall be derived frombool_constant<false>[.](#1.sentence-1)
Implementations may use other algorithms to
compute this relationship to avoid overflow[.](#1.sentence-2)
If overflow occurs, the program is ill-formed[.](#1.sentence-3)
[🔗](#lib:ratio_less_equal)
`template<class R1, class R2>
struct ratio_less_equal : bool_constant<!ratio_less_v<R2, R1>> { };
`
[🔗](#lib:ratio_greater)
`template<class R1, class R2>
struct ratio_greater : bool_constant<ratio_less_v<R2, R1>> { };
`
[🔗](#lib:ratio_greater_equal)
`template<class R1, class R2>
struct ratio_greater_equal : bool_constant<!ratio_less_v<R1, R2>> { };
`