Last active
August 16, 2016 15:07
-
-
Save shotamatsuda/ec4372615f771b7cf69ca62543917ecf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ratio> | |
namespace detail { | |
template <class... Args> | |
struct RatioAdd; | |
template <class R1, class R2> | |
struct RatioAdd<R1, R2> { | |
using Type = std::ratio_add<R1, R2>; | |
}; | |
template <class R1, class R2, class... Args> | |
struct RatioAdd<R1, R2, Args...> { | |
using Type = typename RatioAdd< | |
std::ratio_add<R1, R2>, | |
Args... | |
>::Type; | |
}; | |
template <class... Args> | |
struct RatioSubtract; | |
template <class R1, class R2> | |
struct RatioSubtract<R1, R2> { | |
using Type = std::ratio_subtract<R1, R2>; | |
}; | |
template <class R1, class R2, class... Args> | |
struct RatioSubtract<R1, R2, Args...> { | |
using Type = typename RatioSubtract< | |
std::ratio_subtract<R1, R2>, | |
Args... | |
>::Type; | |
}; | |
template <class... Args> | |
struct RatioMultiply; | |
template <class R1, class R2> | |
struct RatioMultiply<R1, R2> { | |
using Type = std::ratio_multiply<R1, R2>; | |
}; | |
template <class R1, class R2, class... Args> | |
struct RatioMultiply<R1, R2, Args...> { | |
using Type = typename RatioMultiply< | |
std::ratio_multiply<R1, R2>, | |
Args... | |
>::Type; | |
}; | |
template <class... Args> | |
struct RatioDivide; | |
template <class R1, class R2> | |
struct RatioDivide<R1, R2> { | |
using Type = std::ratio_divide<R1, R2>; | |
}; | |
template <class R1, class R2, class... Args> | |
struct RatioDivide<R1, R2, Args...> { | |
using Type = typename RatioDivide< | |
std::ratio_divide<R1, R2>, | |
Args... | |
>::Type; | |
}; | |
} // namespace detail | |
template <class... Args> | |
using RatioAdd = typename detail::RatioAdd<Args...>::Type; | |
template <class... Args> | |
using RatioSubtract = typename detail::RatioSubtract<Args...>::Type; | |
template <class... Args> | |
using RatioMultiply = typename detail::RatioMultiply<Args...>::Type; | |
template <class... Args> | |
using RatioDivide = typename detail::RatioDivide<Args...>::Type; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment