/* Copyright (C) 2015 Povilas Kanapickas This file is part of cppreference-doc This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. */ #ifndef CPPREFERENCE_RATIO_H #define CPPREFERENCE_RATIO_H #if CPPREFERENCE_STDVER>= 2011 #include #include namespace std { template struct ratio { public: typedef ratio type; static constexpr intmax_t num = Num; static constexpr intmax_t den = Denom; }; // only defined if intmax_t can represent the denominator // 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; // only defined if intmax_t can represent the nominator // typedef ratio< 1000000000000000000000, 1> zetta; // typedef ratio<1000000000000000000000000, 1> yotta; // SIMPLIFIED: the following are alias templates template class ratio_add : public ratio<1, 1> {}; template class ratio_subtract : public ratio<1, 1> {}; template class ratio_divide : public ratio<1, 1> {}; template class ratio_multiply : public ratio<1, 1> {}; // SIMPLIFIED: the following inherit from different specialization // of std::integral_constant template struct ratio_equal : std::integral_constant {}; template struct ratio_not_equal : std::integral_constant {}; template struct ratio_less : std::integral_constant {}; template struct ratio_less_equal : std::integral_constant {}; template struct ratio_greater : std::integral_constant {}; template struct ratio_greater_equal : std::integral_constant {}; } // namespace std #endif // CPPREFERENCE_STDVER>= 2011 #endif // CPPREFERENCE_RATIO_H