名稱空間
變體
操作

標準庫標頭檔案 <ratio> (C++11)

來自 cppreference.com
 
 
標準庫標頭檔案
演算法
<algorithm>
<numeric>
字串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文字處理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
數值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
時間
<chrono> (C++11)
<ctime>
C 相容性
<ccomplex> (C++11/17/20*)
<ciso646> (直到 C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此標頭檔案是 編譯時有理算術 庫的一部分。

目錄

(C++11)
表示精確有理分數
(類模板) [編輯]
算術
(C++11)
在編譯時新增兩個 ratio 物件
(別名模板)[編輯]
在編譯時減去兩個 ratio 物件
(別名模板)[編輯]
在編譯時乘以兩個 ratio 物件
(別名模板)[編輯]
在編譯時除以兩個 ratio 物件
(別名模板)[編輯]
比較
在編譯時比較兩個 ratio 物件是否相等
(類模板) [編輯]
在編譯時比較兩個 ratio 物件是否不相等
(類模板) [編輯]
在編譯時比較兩個 ratio 物件是否“小於”
(類模板) [編輯]
在編譯時比較兩個 ratio 物件是否“小於或等於”
(類模板) [編輯]
在編譯時比較兩個 ratio 物件是否“大於”
(類模板) [編輯]
在編譯時比較兩個 ratio 物件是否“大於或等於”
(類模板) [編輯]
類型別名
quecto (C++26) std::ratio<1, 1000000000000000000000000000000>,如果 std::intmax_t 能表示分母
ronto (C++26) std::ratio<1, 1000000000000000000000000000>,如果 std::intmax_t 能表示分母
yocto std::ratio<1, 1000000000000000000000000>,如果 std::intmax_t 能表示分母
zepto std::ratio<1, 1000000000000000000000>,如果 std::intmax_t 能表示分母
atto std::ratio<1, 1000000000000000000>
femto std::ratio<1, 1000000000000000>
pico std::ratio<1, 1000000000000>
nano std::ratio<1, 1000000000>
micro std::ratio<1, 1000000>
milli std::ratio<1, 1000>
centi std::ratio<1, 100>
deci std::ratio<1, 10>
deca std::ratio<10, 1>
hecto std::ratio<100, 1>
kilo std::ratio<1000, 1>
mega std::ratio<1000000, 1>
giga std::ratio<1000000000, 1>
tera std::ratio<1000000000000, 1>
peta std::ratio<1000000000000000, 1>
exa std::ratio<1000000000000000000, 1>
zetta std::ratio<1000000000000000000000, 1>,如果 std::intmax_t 能表示分子
yotta std::ratio<1000000000000000000000000, 1>,如果 std::intmax_t 能表示分子
ronna (C++26) std::ratio<1000000000000000000000000000, 1>,如果 std::intmax_t 能表示分子
quetta (C++26) std::ratio<1000000000000000000000000000000, 1>,如果 std::intmax_t 能表示分子

[編輯] 概要

namespace std {
    // class template ratio
    template <intmax_t N, intmax_t D = 1>
    class ratio {
    public:
        typedef ratio<num, den> type;
        static constexpr intmax_t num;
        static constexpr intmax_t den;
    };
 
    // ratio arithmetic            
    template <class R1, class   R2> using   ratio_add      = /*ratio*/;
    template <class R1, class   R2> using   ratio_subtract = /*ratio*/;
    template <class R1, class   R2> using   ratio_multiply = /*ratio*/;
    template <class R1, class   R2> using   ratio_divide   = /*ratio*/;
 
    // ratio comparison            
    template <class R1, class R2> struct ratio_equal;           
    template <class R1, class R2> struct ratio_not_equal;           
    template <class R1, class R2> struct ratio_less;      
    template <class R1, class R2> struct ratio_less_equal;          
    template <class R1, class R2> struct ratio_greater;         
    template <class R1, class R2> struct ratio_greater_equal;  
 
    // convenience SI typedefs
    typedef ratio<1, 1000000000000000000000000000000> quecto;
    typedef ratio<1,    1000000000000000000000000000> ronto;         
    typedef ratio<1,       1000000000000000000000000> yocto;
    typedef ratio<1,          1000000000000000000000> zepto;
    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;    
    typedef ratio<         1000000000000000000000, 1> zetta;
    typedef ratio<      1000000000000000000000000, 1> yotta;
    typedef ratio<   1000000000000000000000000000, 1> ronna;
    typedef ratio<1000000000000000000000000000000, 1> quetta;
}