ratio 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_RATIO
  10. #define _LIBCPP_RATIO
  11. /*
  12. ratio synopsis
  13. namespace std
  14. {
  15. template <intmax_t N, intmax_t D = 1>
  16. class ratio
  17. {
  18. public:
  19. static constexpr intmax_t num;
  20. static constexpr intmax_t den;
  21. typedef ratio<num, den> type;
  22. };
  23. // ratio arithmetic
  24. template <class R1, class R2> using ratio_add = ...;
  25. template <class R1, class R2> using ratio_subtract = ...;
  26. template <class R1, class R2> using ratio_multiply = ...;
  27. template <class R1, class R2> using ratio_divide = ...;
  28. // ratio comparison
  29. template <class R1, class R2> struct ratio_equal;
  30. template <class R1, class R2> struct ratio_not_equal;
  31. template <class R1, class R2> struct ratio_less;
  32. template <class R1, class R2> struct ratio_less_equal;
  33. template <class R1, class R2> struct ratio_greater;
  34. template <class R1, class R2> struct ratio_greater_equal;
  35. // convenience SI typedefs
  36. using quecto = ratio <1, 1'000'000'000'000'000'000'000'000'000'000>; // Since C++26; not supported
  37. using ronto = ratio <1, 1'000'000'000'000'000'000'000'000'000>; // Since C++26; not supported
  38. typedef ratio<1, 1000000000000000000000000> yocto; // not supported
  39. typedef ratio<1, 1000000000000000000000> zepto; // not supported
  40. typedef ratio<1, 1000000000000000000> atto;
  41. typedef ratio<1, 1000000000000000> femto;
  42. typedef ratio<1, 1000000000000> pico;
  43. typedef ratio<1, 1000000000> nano;
  44. typedef ratio<1, 1000000> micro;
  45. typedef ratio<1, 1000> milli;
  46. typedef ratio<1, 100> centi;
  47. typedef ratio<1, 10> deci;
  48. typedef ratio< 10, 1> deca;
  49. typedef ratio< 100, 1> hecto;
  50. typedef ratio< 1000, 1> kilo;
  51. typedef ratio< 1000000, 1> mega;
  52. typedef ratio< 1000000000, 1> giga;
  53. typedef ratio< 1000000000000, 1> tera;
  54. typedef ratio< 1000000000000000, 1> peta;
  55. typedef ratio< 1000000000000000000, 1> exa;
  56. typedef ratio< 1000000000000000000000, 1> zetta; // not supported
  57. typedef ratio<1000000000000000000000000, 1> yotta; // not supported
  58. using ronna = ratio <1'000'000'000'000'000'000'000'000'000, 1>; // Since C++26; not supported
  59. using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C++26; not supported
  60. // 20.11.5, ratio comparison
  61. template <class R1, class R2> inline constexpr bool ratio_equal_v
  62. = ratio_equal<R1, R2>::value; // C++17
  63. template <class R1, class R2> inline constexpr bool ratio_not_equal_v
  64. = ratio_not_equal<R1, R2>::value; // C++17
  65. template <class R1, class R2> inline constexpr bool ratio_less_v
  66. = ratio_less<R1, R2>::value; // C++17
  67. template <class R1, class R2> inline constexpr bool ratio_less_equal_v
  68. = ratio_less_equal<R1, R2>::value; // C++17
  69. template <class R1, class R2> inline constexpr bool ratio_greater_v
  70. = ratio_greater<R1, R2>::value; // C++17
  71. template <class R1, class R2> inline constexpr bool ratio_greater_equal_v
  72. = ratio_greater_equal<R1, R2>::value; // C++17
  73. }
  74. */
  75. #include <__config>
  76. #include <__type_traits/integral_constant.h>
  77. #include <climits>
  78. #include <cstdint>
  79. #include <version>
  80. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  81. # pragma GCC system_header
  82. #endif
  83. _LIBCPP_PUSH_MACROS
  84. #include <__undef_macros>
  85. _LIBCPP_BEGIN_NAMESPACE_STD
  86. // __static_gcd
  87. template <intmax_t _Xp, intmax_t _Yp>
  88. struct __static_gcd {
  89. static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value;
  90. };
  91. template <intmax_t _Xp>
  92. struct __static_gcd<_Xp, 0> {
  93. static const intmax_t value = _Xp;
  94. };
  95. template <>
  96. struct __static_gcd<0, 0> {
  97. static const intmax_t value = 1;
  98. };
  99. // __static_lcm
  100. template <intmax_t _Xp, intmax_t _Yp>
  101. struct __static_lcm {
  102. static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp;
  103. };
  104. template <intmax_t _Xp>
  105. struct __static_abs {
  106. static const intmax_t value = _Xp < 0 ? -_Xp : _Xp;
  107. };
  108. template <intmax_t _Xp>
  109. struct __static_sign {
  110. static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
  111. };
  112. template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
  113. class __ll_add;
  114. template <intmax_t _Xp, intmax_t _Yp>
  115. class __ll_add<_Xp, _Yp, 1> {
  116. static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
  117. static const intmax_t max = -min;
  118. static_assert(_Xp <= max - _Yp, "overflow in __ll_add");
  119. public:
  120. static const intmax_t value = _Xp + _Yp;
  121. };
  122. template <intmax_t _Xp, intmax_t _Yp>
  123. class __ll_add<_Xp, _Yp, 0> {
  124. public:
  125. static const intmax_t value = _Xp;
  126. };
  127. template <intmax_t _Xp, intmax_t _Yp>
  128. class __ll_add<_Xp, _Yp, -1> {
  129. static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
  130. static const intmax_t max = -min;
  131. static_assert(min - _Yp <= _Xp, "overflow in __ll_add");
  132. public:
  133. static const intmax_t value = _Xp + _Yp;
  134. };
  135. template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
  136. class __ll_sub;
  137. template <intmax_t _Xp, intmax_t _Yp>
  138. class __ll_sub<_Xp, _Yp, 1> {
  139. static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
  140. static const intmax_t max = -min;
  141. static_assert(min + _Yp <= _Xp, "overflow in __ll_sub");
  142. public:
  143. static const intmax_t value = _Xp - _Yp;
  144. };
  145. template <intmax_t _Xp, intmax_t _Yp>
  146. class __ll_sub<_Xp, _Yp, 0> {
  147. public:
  148. static const intmax_t value = _Xp;
  149. };
  150. template <intmax_t _Xp, intmax_t _Yp>
  151. class __ll_sub<_Xp, _Yp, -1> {
  152. static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
  153. static const intmax_t max = -min;
  154. static_assert(_Xp <= max + _Yp, "overflow in __ll_sub");
  155. public:
  156. static const intmax_t value = _Xp - _Yp;
  157. };
  158. template <intmax_t _Xp, intmax_t _Yp>
  159. class __ll_mul {
  160. static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
  161. static const intmax_t min = nan + 1;
  162. static const intmax_t max = -min;
  163. static const intmax_t __a_x = __static_abs<_Xp>::value;
  164. static const intmax_t __a_y = __static_abs<_Yp>::value;
  165. static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");
  166. public:
  167. static const intmax_t value = _Xp * _Yp;
  168. };
  169. template <intmax_t _Yp>
  170. class __ll_mul<0, _Yp> {
  171. public:
  172. static const intmax_t value = 0;
  173. };
  174. template <intmax_t _Xp>
  175. class __ll_mul<_Xp, 0> {
  176. public:
  177. static const intmax_t value = 0;
  178. };
  179. template <>
  180. class __ll_mul<0, 0> {
  181. public:
  182. static const intmax_t value = 0;
  183. };
  184. // Not actually used but left here in case needed in future maintenance
  185. template <intmax_t _Xp, intmax_t _Yp>
  186. class __ll_div {
  187. static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
  188. static const intmax_t min = nan + 1;
  189. static const intmax_t max = -min;
  190. static_assert(_Xp != nan && _Yp != nan && _Yp != 0, "overflow in __ll_div");
  191. public:
  192. static const intmax_t value = _Xp / _Yp;
  193. };
  194. template <intmax_t _Num, intmax_t _Den = 1>
  195. class _LIBCPP_TEMPLATE_VIS ratio {
  196. static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
  197. static_assert(_Den != 0, "ratio divide by 0");
  198. static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");
  199. static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;
  200. static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;
  201. static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
  202. static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
  203. public:
  204. static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
  205. static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
  206. typedef ratio<num, den> type;
  207. };
  208. template <intmax_t _Num, intmax_t _Den>
  209. _LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
  210. template <intmax_t _Num, intmax_t _Den>
  211. _LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
  212. template <class _Tp>
  213. struct __is_ratio : false_type {};
  214. template <intmax_t _Num, intmax_t _Den>
  215. struct __is_ratio<ratio<_Num, _Den> > : true_type {};
  216. typedef ratio<1LL, 1000000000000000000LL> atto;
  217. typedef ratio<1LL, 1000000000000000LL> femto;
  218. typedef ratio<1LL, 1000000000000LL> pico;
  219. typedef ratio<1LL, 1000000000LL> nano;
  220. typedef ratio<1LL, 1000000LL> micro;
  221. typedef ratio<1LL, 1000LL> milli;
  222. typedef ratio<1LL, 100LL> centi;
  223. typedef ratio<1LL, 10LL> deci;
  224. typedef ratio< 10LL, 1LL> deca;
  225. typedef ratio< 100LL, 1LL> hecto;
  226. typedef ratio< 1000LL, 1LL> kilo;
  227. typedef ratio< 1000000LL, 1LL> mega;
  228. typedef ratio< 1000000000LL, 1LL> giga;
  229. typedef ratio< 1000000000000LL, 1LL> tera;
  230. typedef ratio< 1000000000000000LL, 1LL> peta;
  231. typedef ratio<1000000000000000000LL, 1LL> exa;
  232. template <class _R1, class _R2>
  233. struct __ratio_multiply {
  234. private:
  235. static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;
  236. static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;
  237. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  238. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  239. public:
  240. typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
  241. __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type;
  242. };
  243. #ifndef _LIBCPP_CXX03_LANG
  244. template <class _R1, class _R2>
  245. using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
  246. #else // _LIBCPP_CXX03_LANG
  247. template <class _R1, class _R2>
  248. struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {};
  249. #endif // _LIBCPP_CXX03_LANG
  250. template <class _R1, class _R2>
  251. struct __ratio_divide {
  252. private:
  253. static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
  254. static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
  255. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  256. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  257. public:
  258. typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
  259. __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type;
  260. };
  261. #ifndef _LIBCPP_CXX03_LANG
  262. template <class _R1, class _R2>
  263. using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
  264. #else // _LIBCPP_CXX03_LANG
  265. template <class _R1, class _R2>
  266. struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {};
  267. #endif // _LIBCPP_CXX03_LANG
  268. template <class _R1, class _R2>
  269. struct __ratio_add {
  270. private:
  271. static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
  272. static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
  273. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  274. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  275. public:
  276. typedef typename ratio_multiply<
  277. ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
  278. ratio< __ll_add< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
  279. __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::value,
  280. _R2::den > >::type type;
  281. };
  282. #ifndef _LIBCPP_CXX03_LANG
  283. template <class _R1, class _R2>
  284. using ratio_add = typename __ratio_add<_R1, _R2>::type;
  285. #else // _LIBCPP_CXX03_LANG
  286. template <class _R1, class _R2>
  287. struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {};
  288. #endif // _LIBCPP_CXX03_LANG
  289. template <class _R1, class _R2>
  290. struct __ratio_subtract {
  291. private:
  292. static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
  293. static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
  294. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  295. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  296. public:
  297. typedef typename ratio_multiply<
  298. ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
  299. ratio< __ll_sub< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
  300. __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::value,
  301. _R2::den > >::type type;
  302. };
  303. #ifndef _LIBCPP_CXX03_LANG
  304. template <class _R1, class _R2>
  305. using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
  306. #else // _LIBCPP_CXX03_LANG
  307. template <class _R1, class _R2>
  308. struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {};
  309. #endif // _LIBCPP_CXX03_LANG
  310. // ratio_equal
  311. template <class _R1, class _R2>
  312. struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {
  313. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  314. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  315. };
  316. template <class _R1, class _R2>
  317. struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {
  318. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  319. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  320. };
  321. // ratio_less
  322. template <class _R1,
  323. class _R2,
  324. bool _Odd = false,
  325. intmax_t _Q1 = _R1::num / _R1::den,
  326. intmax_t _M1 = _R1::num % _R1::den,
  327. intmax_t _Q2 = _R2::num / _R2::den,
  328. intmax_t _M2 = _R2::num % _R2::den>
  329. struct __ratio_less1 {
  330. static const bool value = _Odd ? _Q2 < _Q1 : _Q1 < _Q2;
  331. };
  332. template <class _R1, class _R2, bool _Odd, intmax_t _Qp>
  333. struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, 0> {
  334. static const bool value = false;
  335. };
  336. template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M2>
  337. struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, _M2> {
  338. static const bool value = !_Odd;
  339. };
  340. template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1>
  341. struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, 0> {
  342. static const bool value = _Odd;
  343. };
  344. template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1, intmax_t _M2>
  345. struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2> {
  346. static const bool value = __ratio_less1<ratio<_R1::den, _M1>, ratio<_R2::den, _M2>, !_Odd>::value;
  347. };
  348. template <class _R1,
  349. class _R2,
  350. intmax_t _S1 = __static_sign<_R1::num>::value,
  351. intmax_t _S2 = __static_sign<_R2::num>::value>
  352. struct __ratio_less {
  353. static const bool value = _S1 < _S2;
  354. };
  355. template <class _R1, class _R2>
  356. struct __ratio_less<_R1, _R2, 1LL, 1LL> {
  357. static const bool value = __ratio_less1<_R1, _R2>::value;
  358. };
  359. template <class _R1, class _R2>
  360. struct __ratio_less<_R1, _R2, -1LL, -1LL> {
  361. static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value;
  362. };
  363. template <class _R1, class _R2>
  364. struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {
  365. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  366. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  367. };
  368. template <class _R1, class _R2>
  369. struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {
  370. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  371. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  372. };
  373. template <class _R1, class _R2>
  374. struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {
  375. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  376. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  377. };
  378. template <class _R1, class _R2>
  379. struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {
  380. static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
  381. static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
  382. };
  383. template <class _R1, class _R2>
  384. struct __ratio_gcd {
  385. typedef ratio<__static_gcd<_R1::num, _R2::num>::value, __static_lcm<_R1::den, _R2::den>::value> type;
  386. };
  387. #if _LIBCPP_STD_VER >= 17
  388. template <class _R1, class _R2>
  389. inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
  390. template <class _R1, class _R2>
  391. inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
  392. template <class _R1, class _R2>
  393. inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
  394. template <class _R1, class _R2>
  395. inline constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
  396. template <class _R1, class _R2>
  397. inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
  398. template <class _R1, class _R2>
  399. inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
  400. #endif
  401. _LIBCPP_END_NAMESPACE_STD
  402. _LIBCPP_POP_MACROS
  403. #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
  404. # include <type_traits>
  405. #endif
  406. #endif // _LIBCPP_RATIO