On Sat, 2 May 2015, Jonathan Wakely wrote:

These where simple to implement (almost too simple ... I probably
got something wrong!)

I didn't remember that std::abs works for unsigned. It will need more work for performance, but that can certainly be done later (I didn't look at the code beyond checking what you meant by "simple").

(Apart from using common_type_t, which is easy to change, these
functions meet the simpler rules for C++11 constexpr, so moving them
out of <experimental/numeric> would probably allow <ratio> to be
greatly simplified. I don't plan on doing that myself any time soon,
but it would make sense to do it some day.)

gcd is not really the hard part in ratio. But constexpr should help, it made sense not to have it in tr1, but I don't remember why we didn't use it in the more recent changes (2011, the compiler probably already supported constexpr). Maybe the interesting functions were too hard to write as one-liners...

--
Marc Glisse

Reply via email to