http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45866
Summary: std::ratio_add, ratio_sub, ratio_multiply,
ratio_divide do not have num and den members.
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: [email protected]
ReportedBy: [email protected]
The latest C++ draft (which I think is n3126) says this about ratio_add:
"The type ratio_add<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has
the value R1::num * R2::den + R2::num * R1::den and T2 has the value R1::den *
R2::den."
The current implementation in libstdc++ is:
template<typename _R1, typename _R2>
struct ratio_add
{
private:
static const intmax_t __gcd =
__static_gcd<_R1::den, _R2::den>::value;
public:
typedef ratio<
__safe_add<
__safe_multiply<_R1::num, (_R2::den / __gcd)>::value,
__safe_multiply<_R2::num, (_R1::den / __gcd)>::value>::value,
__safe_multiply<_R1::den, (_R2::den / __gcd)>::value> type;
};
Which places the result in a nested type. I interpret the wording of the
standard to mean that ratio_add<R1, R2> should have the static members num and
den.