I was looking at the class std::ratio<>
from the C++11 standard that allows to make compile-time rational arithmetic.
I found the template design and the operations implemented with classes overly complex and did not find any reason why they could not just use a more straightforward and intuitive approach by implementing a really simple rational class and defining constexpr
functions for the operators. The result would have been a class easier to use and the compile-time advantages would have remained.
Does anyone have any idea of the advantages of the current std::ratio<>
design compared to a simple class implementation using constexpr
? Actually, I can't manage to find any advantage to the current implementation.