// ratio -*- C++ -*-
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
: integral_constant<bool, !ratio_equal<_R1, _R2>::value>
{ };
- template<typename _R1>
+ // 0 <= _Ri < 1
+ template<typename _R1, typename _R2>
+ struct __ratio_less_impl_2;
+
+ // _Ri > 0
+ template<typename _R1, typename _R2, intmax_t __q1 = _R1::num / _R1::den,
+ intmax_t __q2 = _R2::num / _R2::den, bool __eq = (__q1 == __q2)>
struct __ratio_less_impl_1
- : integral_constant<bool, _R1::num < _R1::den>
+ : __ratio_less_impl_2<ratio<_R1::num % _R1::den, _R1::den>,
+ ratio<_R2::num % _R2::den, _R2::den> >::type
+ { };
+
+ template<typename _R1, typename _R2, intmax_t __q1, intmax_t __q2>
+ struct __ratio_less_impl_1<_R1, _R2, __q1, __q2, false>
+ : integral_constant<bool, (__q1 < __q2) >
+ { };
+
+ template<typename _R1, typename _R2>
+ struct __ratio_less_impl_2
+ : __ratio_less_impl_1<ratio<_R2::den, _R2::num>,
+ ratio<_R1::den, _R1::num> >::type
+ { };
+
+ template<intmax_t __d1, typename _R2>
+ struct __ratio_less_impl_2<ratio<0, __d1>, _R2>
+ : integral_constant<bool, true>
+ { };
+
+ template<typename _R1, intmax_t __d2>
+ struct __ratio_less_impl_2<_R1, ratio<0, __d2> >
+ : integral_constant<bool, false>
+ { };
+
+ template<intmax_t __d1, intmax_t __d2>
+ struct __ratio_less_impl_2<ratio<0, __d1>, ratio<0, __d2> >
+ : integral_constant<bool, false>
{ };
template<typename _R1, typename _R2,
bool = (__static_sign<_R1::num>::value == -1
&& __static_sign<_R2::num>::value == -1)>
struct __ratio_less_impl
- : __ratio_less_impl_1<typename ratio_divide<_R1, _R2>::type>::type
+ : __ratio_less_impl_1<_R1, _R2>::type
{ };
template<typename _R1, typename _R2>
template<typename _R1, typename _R2>
struct __ratio_less_impl<_R1, _R2, false, true>
- : __ratio_less_impl_1<typename ratio_divide<_R2, _R1>::type>::type
+ : __ratio_less_impl_1<ratio<-_R2::num, _R2::den>,
+ ratio<-_R1::num, _R1::den> >::type
{ };
/// ratio_less