Namespaces
Variants
Actions

Talk:cpp/numeric/ratio/ratio

From cppreference.com

[edit] Good way to phrase std::ratio's behavior?

std::ratio is a little odd in that its members always uses the numerator and denominator reduced to lowest terms - std::ratio<2, 4>::num == 1 && std::ratio<2, 4>::den == 2, for instance. Similarly, std::ratio<2, 4>::type is std::ratio<1, 2> (::type is in fact the way to reduce a std::ratio to an irreducible fraction).

However, std::ratio<2,4> and std::ratio<1,2> are completely distinct types, even though all of their members have the same value. I can't think of a good way to phrase this, though. The current wording ("Both numerator and denominator are automatically reduced to the lowest terms.") may be read to imply that std::ratio<2,4> and std::ratio<1,2> are the same type, which is not the case. T. Canens (talk) 16:43, 23 May 2015 (PDT)