/
usr
/
include
/
c++
/
4.4.4
/
/usr/include/c++/4.4.4
mkdir
upload
Name
Size
Mode
Actions
backward/
-
0755
rm
bits/
-
0755
rm
debug/
-
0755
rm
ext/
-
0755
rm
parallel/
-
0755
rm
tr1/
-
0755
rm
tr1_impl/
-
0755
rm
x86_64-redhat-linux/
-
0755
rm
algorithm
2528
0644
edit
dl
rm
array
1861
0644
edit
dl
rm
bitset
38246
0644
edit
dl
rm
c++0x_warning.h
1441
0644
edit
dl
rm
cassert
1691
0644
edit
dl
rm
ccomplex
1425
0644
edit
dl
rm
cctype
2862
0644
edit
dl
rm
cerrno
1813
0644
edit
dl
rm
cfenv
1872
0644
edit
dl
rm
cfloat
2046
0644
edit
dl
rm
chrono
21125
0644
edit
dl
rm
cinttypes
2151
0644
edit
dl
rm
ciso646
1513
0644
edit
dl
rm
climits
1956
0644
edit
dl
rm
clocale
1996
0644
edit
dl
rm
cmath
15560
0644
edit
dl
rm
complex
42262
0644
edit
dl
rm
complex.h
1374
0644
edit
dl
rm
condition_variable
6208
0644
edit
dl
rm
csetjmp
2040
0644
edit
dl
rm
csignal
1946
0644
edit
dl
rm
cstdarg
1935
0644
edit
dl
rm
cstdatomic
24336
0644
edit
dl
rm
cstdbool
1412
0644
edit
dl
rm
cstddef
1830
0644
edit
dl
rm
cstdint
2374
0644
edit
dl
rm
cstdio
4812
0644
edit
dl
rm
cstdlib
5723
0644
edit
dl
rm
cstring
3261
0644
edit
dl
rm
ctgmath
1327
0644
edit
dl
rm
ctime
2211
0644
edit
dl
rm
cwchar
6538
0644
edit
dl
rm
cwctype
3294
0644
edit
dl
rm
cxxabi-forced.h
1631
0644
edit
dl
rm
cxxabi.h
19106
0644
edit
dl
rm
deque
2658
0644
edit
dl
rm
exception
4856
0644
edit
dl
rm
exception_defines.h
1648
0644
edit
dl
rm
exception_ptr.h
4355
0644
edit
dl
rm
fenv.h
1888
0644
edit
dl
rm
forward_list
1480
0644
edit
dl
rm
fstream
29267
0644
edit
dl
rm
functional
2658
0644
edit
dl
rm
initializer_list
1987
0644
edit
dl
rm
iomanip
8696
0644
edit
dl
rm
ios
1658
0644
edit
dl
rm
iosfwd
6017
0644
edit
dl
rm
iostream
2654
0644
edit
dl
rm
istream
28304
0644
edit
dl
rm
iterator
2639
0644
edit
dl
rm
limits
45520
0644
edit
dl
rm
list
2588
0644
edit
dl
rm
locale
1480
0644
edit
dl
rm
map
2479
0644
edit
dl
rm
memory
3356
0644
edit
dl
rm
mutex
18380
0644
edit
dl
rm
new
3735
0644
edit
dl
rm
numeric
2808
0644
edit
dl
rm
ostream
18442
0644
edit
dl
rm
queue
2507
0644
edit
dl
rm
random
2086
0644
edit
dl
rm
ratio
9176
0644
edit
dl
rm
regex
2002
0644
edit
dl
rm
set
2479
0644
edit
dl
rm
sstream
18876
0644
edit
dl
rm
stack
2431
0644
edit
dl
rm
stdatomic.h
7263
0644
edit
dl
rm
stdexcept
4247
0644
edit
dl
rm
streambuf
28107
0644
edit
dl
rm
string
2021
0644
edit
dl
rm
system_error
9434
0644
edit
dl
rm
tgmath.h
1368
0644
edit
dl
rm
thread
6562
0644
edit
dl
rm
tuple
21068
0644
edit
dl
rm
typeinfo
7170
0644
edit
dl
rm
type_traits
17152
0644
edit
dl
rm
unordered_map
2448
0644
edit
dl
rm
unordered_set
2448
0644
edit
dl
rm
utility
3320
0644
edit
dl
rm
valarray
36486
0644
edit
dl
rm
vector
2698
0644
edit
dl
rm
Edit:
/usr/include/c++/4.4.4/ratio
(9176B)
// ratio -*- C++ -*- // Copyright (C) 2008, 2009 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 // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file ratio * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_RATIO #define _GLIBCXX_RATIO 1 #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <c++0x_warning.h> #else #include <type_traits> #include <cstdint> #ifdef _GLIBCXX_USE_C99_STDINT_TR1 namespace std { /** * @defgroup ratio Rational Arithmetic * @ingroup utilities * * Compile time representation of fininte rational numbers. * @{ */ template<intmax_t _Pn> struct __static_sign : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1> { }; template<intmax_t _Pn> struct __static_abs : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value> { }; template<intmax_t _Pn, intmax_t _Qn> struct __static_gcd; template<intmax_t _Pn, intmax_t _Qn> struct __static_gcd : __static_gcd<_Qn, (_Pn % _Qn)> { }; template<intmax_t _Pn> struct __static_gcd<_Pn, 0> : integral_constant<intmax_t, __static_abs<_Pn>::value> { }; template<intmax_t _Qn> struct __static_gcd<0, _Qn> : integral_constant<intmax_t, __static_abs<_Qn>::value> { }; // Let c = 2^(half # of bits in an intmax_t) // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0 // The multiplication of N and M becomes, // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0 // Multiplication is safe if each term and the sum of the terms // is representable by intmax_t. template<intmax_t _Pn, intmax_t _Qn> struct __safe_multiply { private: static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); static const uintmax_t __a0 = __static_abs<_Pn>::value % __c; static const uintmax_t __a1 = __static_abs<_Pn>::value / __c; static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; static_assert(__a1 == 0 || __b1 == 0, "overflow in multiplication"); static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), "overflow in multiplication"); static_assert(__b0 * __a0 <= __INTMAX_MAX__, "overflow in multiplication"); static_assert((__a0 * __b1 + __b0 * __a1) * __c <= __INTMAX_MAX__ - __b0 * __a0, "overflow in multiplication"); public: static const intmax_t value = _Pn * _Qn; }; // Helpers for __safe_add template<intmax_t _Pn, intmax_t _Qn, bool> struct __add_overflow_check_impl : integral_constant<bool, (_Pn <= __INTMAX_MAX__ - _Qn)> { }; template<intmax_t _Pn, intmax_t _Qn> struct __add_overflow_check_impl<_Pn, _Qn, false> : integral_constant<bool, (_Pn >= -__INTMAX_MAX__ - _Qn)> { }; template<intmax_t _Pn, intmax_t _Qn> struct __add_overflow_check : __add_overflow_check_impl<_Pn, _Qn, (_Qn >= 0)> { }; template<intmax_t _Pn, intmax_t _Qn> struct __safe_add { static_assert(__add_overflow_check<_Pn, _Qn>::value != 0, "overflow in addition"); static const intmax_t value = _Pn + _Qn; }; /** * @brief Provides compile-time rational arithmetic. * * This class template represents any finite rational number with a * numerator and denominator representable by compile-time constants of * type intmax_t. The ratio is simplified when instantiated. * * For example: * @code * std::ratio<7,-21>::num == -1; * std::ratio<7,-21>::den == 3; * @endcode * */ template<intmax_t _Num, intmax_t _Den = 1> struct ratio { static_assert(_Den != 0, "denominator cannot be zero"); static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__, "out of range"); // Note: sign(N) * abs(N) == N static const intmax_t num = _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value; static const intmax_t den = __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value; }; template<intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num; template<intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den; /// ratio_add template<typename _R1, typename _R2> struct ratio_add { private: static const intmax_t __gcd = __static_gcd<_R1::den, _R2::den>::value; public: typedef ratio< __safe_add< __safe_multiply<_R1::num, (_R2::den / __gcd)>::value, __safe_multiply<_R2::num, (_R1::den / __gcd)>::value>::value, __safe_multiply<_R1::den, (_R2::den / __gcd)>::value> type; }; /// ratio_subtract template<typename _R1, typename _R2> struct ratio_subtract { typedef typename ratio_add< _R1, ratio<-_R2::num, _R2::den>>::type type; }; /// ratio_multiply template<typename _R1, typename _R2> struct ratio_multiply { private: static const intmax_t __gcd1 = __static_gcd<_R1::num, _R2::den>::value; static const intmax_t __gcd2 = __static_gcd<_R2::num, _R1::den>::value; public: typedef ratio< __safe_multiply<(_R1::num / __gcd1), (_R2::num / __gcd2)>::value, __safe_multiply<(_R1::den / __gcd2), (_R2::den / __gcd1)>::value> type; }; /// ratio_divide template<typename _R1, typename _R2> struct ratio_divide { static_assert(_R2::num != 0, "division by 0"); typedef typename ratio_multiply< _R1, ratio<_R2::den, _R2::num>>::type type; }; /// ratio_equal template<typename _R1, typename _R2> struct ratio_equal : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> { }; /// ratio_not_equal template<typename _R1, typename _R2> struct ratio_not_equal : integral_constant<bool, !ratio_equal<_R1, _R2>::value> { }; template<typename _R1, typename _R2> struct __ratio_less_simple_impl : integral_constant<bool, (__safe_multiply<_R1::num, _R2::den>::value < __safe_multiply<_R2::num, _R1::den>::value)> { }; // If the denominators are equal or the signs differ, we can just compare // numerators, otherwise fallback to the simple cross-multiply method. template<typename _R1, typename _R2> struct __ratio_less_impl : conditional<(_R1::den == _R2::den || (__static_sign<_R1::num>::value != __static_sign<_R2::num>::value)), integral_constant<bool, (_R1::num < _R2::num)>, __ratio_less_simple_impl<_R1, _R2>>::type { }; /// ratio_less template<typename _R1, typename _R2> struct ratio_less : __ratio_less_impl<_R1, _R2>::type { }; /// ratio_less_equal template<typename _R1, typename _R2> struct ratio_less_equal : integral_constant<bool, !ratio_less<_R2, _R1>::value> { }; /// ratio_greater template<typename _R1, typename _R2> struct ratio_greater : integral_constant<bool, ratio_less<_R2, _R1>::value> { }; /// ratio_greater_equal template<typename _R1, typename _R2> struct ratio_greater_equal : integral_constant<bool, !ratio_less<_R1, _R2>::value> { }; typedef ratio<1, 1000000000000000000> atto; typedef ratio<1, 1000000000000000> femto; typedef ratio<1, 1000000000000> pico; typedef ratio<1, 1000000000> nano; typedef ratio<1, 1000000> micro; typedef ratio<1, 1000> milli; typedef ratio<1, 100> centi; typedef ratio<1, 10> deci; typedef ratio< 10, 1> deca; typedef ratio< 100, 1> hecto; typedef ratio< 1000, 1> kilo; typedef ratio< 1000000, 1> mega; typedef ratio< 1000000000, 1> giga; typedef ratio< 1000000000000, 1> tera; typedef ratio< 1000000000000000, 1> peta; typedef ratio< 1000000000000000000, 1> exa; // @} group ratio } #endif //_GLIBCXX_USE_C99_STDINT_TR1 #endif //__GXX_EXPERIMENTAL_CXX0X__ #endif //_GLIBCXX_RATIO
Save
cmd:
run