/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    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 <cstdint>
#include <type_traits>

namespace std {

template<std::intmax_t Num,
         std::intmax_t Denom = 1>
struct ratio {
public:
    typedef ratio<Num, Denom> type;
    static constexpr intmax_t num;
    static constexpr intmax_t den;
};

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;

// SIMPLIFIED: the following are alias templates
template<class R1, class R2>
class ratio_add : public ratio<1, 1> {};
template<class R1, class R2>
class ratio_subtract : public ratio<1, 1> {};
template<class R1, class R2>
class ratio_divide : public ratio<1, 1> {};
template<class R1, class R2>
class ratio_multiply : public ratio<1, 1> {};

// SIMPLIFIED: the following inherit from different specialization
// of std::integral_constant
template<class R1, class R2>
struct ratio_equal : std::integral_constant<bool, true> {};
template<class R1, class R2>
struct ratio_not_equal : std::integral_constant<bool, true> {};
template<class R1, class R2>
struct ratio_less : std::integral_constant<bool, true> {};
template<class R1, class R2>
struct ratio_less_equal : std::integral_constant<bool, true> {};
template<class R1, class R2>
struct ratio_greater : std::integral_constant<bool, true> {};
template<class R1, class R2>
struct ratio_greater_equal : std::integral_constant<bool, true> {};

} // namespace std

#endif // CPPREFERENCE_STDVER>= 2011

#endif // CPPREFERENCE_RATIO_H
