comparison libcxx/include/ratio @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children 1f2b6ac9f198
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
1 // -*- C++ -*- 1 // -*- C++ -*-
2 //===---------------------------- ratio -----------------------------------===// 2 //===----------------------------------------------------------------------===//
3 // 3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 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. 5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 // 7 //
75 template <class R1, class R2> inline constexpr bool ratio_greater_equal_v 75 template <class R1, class R2> inline constexpr bool ratio_greater_equal_v
76 = ratio_greater_equal<R1, R2>::value; // C++17 76 = ratio_greater_equal<R1, R2>::value; // C++17
77 } 77 }
78 */ 78 */
79 79
80 #include <__assert> // all public C++ headers provide the assertion handler
80 #include <__config> 81 #include <__config>
81 #include <climits> 82 #include <climits>
82 #include <cstdint> 83 #include <cstdint>
83 #include <type_traits> 84 #include <type_traits>
85 #include <version>
84 86
85 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 87 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
86 #pragma GCC system_header 88 # pragma GCC system_header
87 #endif 89 #endif
88 90
89 _LIBCPP_PUSH_MACROS 91 _LIBCPP_PUSH_MACROS
90 #include <__undef_macros> 92 #include <__undef_macros>
91 93
413 415
414 // ratio_equal 416 // ratio_equal
415 417
416 template <class _R1, class _R2> 418 template <class _R1, class _R2>
417 struct _LIBCPP_TEMPLATE_VIS ratio_equal 419 struct _LIBCPP_TEMPLATE_VIS ratio_equal
418 : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {}; 420 : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {};
419 421
420 template <class _R1, class _R2> 422 template <class _R1, class _R2>
421 struct _LIBCPP_TEMPLATE_VIS ratio_not_equal 423 struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
422 : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {}; 424 : _BoolConstant<!ratio_equal<_R1, _R2>::value> {};
423 425
424 // ratio_less 426 // ratio_less
425 427
426 template <class _R1, class _R2, bool _Odd = false, 428 template <class _R1, class _R2, bool _Odd = false,
427 intmax_t _Q1 = _R1::num / _R1::den, intmax_t _M1 = _R1::num % _R1::den, 429 intmax_t _Q1 = _R1::num / _R1::den, intmax_t _M1 = _R1::num % _R1::den,
476 static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value; 478 static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value;
477 }; 479 };
478 480
479 template <class _R1, class _R2> 481 template <class _R1, class _R2>
480 struct _LIBCPP_TEMPLATE_VIS ratio_less 482 struct _LIBCPP_TEMPLATE_VIS ratio_less
481 : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {}; 483 : _BoolConstant<__ratio_less<_R1, _R2>::value> {};
482 484
483 template <class _R1, class _R2> 485 template <class _R1, class _R2>
484 struct _LIBCPP_TEMPLATE_VIS ratio_less_equal 486 struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
485 : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {}; 487 : _BoolConstant<!ratio_less<_R2, _R1>::value> {};
486 488
487 template <class _R1, class _R2> 489 template <class _R1, class _R2>
488 struct _LIBCPP_TEMPLATE_VIS ratio_greater 490 struct _LIBCPP_TEMPLATE_VIS ratio_greater
489 : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {}; 491 : _BoolConstant<ratio_less<_R2, _R1>::value> {};
490 492
491 template <class _R1, class _R2> 493 template <class _R1, class _R2>
492 struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal 494 struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
493 : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {}; 495 : _BoolConstant<!ratio_less<_R1, _R2>::value> {};
494 496
495 template <class _R1, class _R2> 497 template <class _R1, class _R2>
496 struct __ratio_gcd 498 struct __ratio_gcd
497 { 499 {
498 typedef ratio<__static_gcd<_R1::num, _R2::num>::value, 500 typedef ratio<__static_gcd<_R1::num, _R2::num>::value,
499 __static_lcm<_R1::den, _R2::den>::value> type; 501 __static_lcm<_R1::den, _R2::den>::value> type;
500 }; 502 };
501 503
502 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) 504 #if _LIBCPP_STD_VER > 14
503 template <class _R1, class _R2> 505 template <class _R1, class _R2>
504 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_equal_v 506 inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
505 = ratio_equal<_R1, _R2>::value; 507
506 508 template <class _R1, class _R2>
507 template <class _R1, class _R2> 509 inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
508 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_not_equal_v 510
509 = ratio_not_equal<_R1, _R2>::value; 511 template <class _R1, class _R2>
510 512 inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
511 template <class _R1, class _R2> 513
512 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_v 514 template <class _R1, class _R2>
513 = ratio_less<_R1, _R2>::value; 515 inline constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
514 516
515 template <class _R1, class _R2> 517 template <class _R1, class _R2>
516 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_equal_v 518 inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
517 = ratio_less_equal<_R1, _R2>::value; 519
518 520 template <class _R1, class _R2>
519 template <class _R1, class _R2> 521 inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
520 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_v
521 = ratio_greater<_R1, _R2>::value;
522
523 template <class _R1, class _R2>
524 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
525 = ratio_greater_equal<_R1, _R2>::value;
526 #endif 522 #endif
527 523
528 _LIBCPP_END_NAMESPACE_STD 524 _LIBCPP_END_NAMESPACE_STD
529 525
530 _LIBCPP_POP_MACROS 526 _LIBCPP_POP_MACROS