*This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.*

**Section:** 21.4.4 [ratio.arithmetic] **Status:** Resolved
**Submitter:** BSI **Opened:** 2010-08-25 **Last modified:** 2016-02-10

**Priority: **Not Prioritized

**View all other** issues in [ratio.arithmetic].

**View all issues with** Resolved status.

**Discussion:**

**Addresses GB-89**

The alias representations of the `ratio` arithmetic templates
do not allow implementations to avoid overflow, since they
explicitly specify the form of the aliased template
instantiation. For example
`ratio_multiply`, `ratio<2, LLONG_MAX>` is *required* to
alias `ratio<2*LLONG_MAX, LLONG_MAX*2>`, which
overflows, so is ill-formed. However, this is trivially equal
to `ratio<1, 1>`. It also contradicts the opening statement of
21.4.4 [ratio.arithmetic] p. 1 "implementations may use other algorithms to
compute these values".

*[
2010-10-25 Daniel adds:
]*

Accepting n3131 would solve this issue.

*[Batavia: Resolved by accepting
n3210.]*

**Proposed resolution:**

Change the wording in 21.4.4 [ratio.arithmetic] p. 2-5 as follows:

template <class R1, class R2> using ratio_add =see below;2 The type

ratio_add<R1, R2>shall be a synonym forratio<T1, T2>ratio<U, V>such thatratio<U, V>::numandratio<U, V>::denare the same as the corresponding members ofratio<T1, T2>would be in the absence of arithmetic overflow whereT1has the valueR1::num * R2::den + R2::num * R1::denandT2has the valueR1::den * R2::den. If the required values ofratio<U, V>::numandratio<U, V>::dencannot be represented inintmax_tthen the program is ill-formed.

template <class R1, class R2> using ratio_subtract =see below;3 The type

ratio_subtract<R1, R2>shall be a synonym forratio<T1, T2>ratio<U, V>such thatratio<U, V>::numandratio<U, V>::denare the same as the corresponding members ofratio<T1, T2>would be in the absence of arithmetic overflow whereT1has the valueR1::num * R2::den - R2::num * R1::denandT2has the valueR1::den * R2::den. If the required values ofratio<U, V>::numandratio<U, V>::dencannot be represented inintmax_tthen the program is ill-formed.

template <class R1, class R2> using ratio_multiply =see below;4 The type

ratio_multiply<R1, R2>shall be a synonym forratio<T1, T2>ratio<U, V>such thatratio<U, V>::numandratio<U, V>::denare the same as the corresponding members ofratio<T1, T2>would be in the absence of arithmetic overflow whereT1has the valueR1::num * R2::numandT2has the valueR1::den * R2::den. If the required values ofratio<U, V>::numandratio<U, V>::dencannot be represented inintmax_tthen the program is ill-formed.

template <class R1, class R2> using ratio_divide =see below;5 The type

ratio_divide<R1, R2>shall be a synonym forratio<T1, T2>ratio<U, V>such thatratio<U, V>::numandratio<U, V>::denare the same as the corresponding members ofratio<T1, T2>would be in the absence of arithmetic overflow whereT1has the valueR1::num * R2::denandT2has the valueR1::den * R2::num. If the required values ofratio<U, V>::numandratio<U, V>::dencannot be represented inintmax_tthen the program is ill-formed.