Title
Fixing duration division
Status
c++20
Section
[time.duration.nonmember]
Submitter
Johel Ernesto Guerrero Peña

Created on 2018-04-17.00:00:00 last changed 38 months ago

Messages

Date: 2018-06-12.01:05:16

Proposed resolution:

This wording is relative to N4741.

  1. Edit [time.duration.nonmember] as indicated:

    -1- In the function descriptions that follow, unless stated otherwise, let CD represents the return type of the function.

    […]

    template<class Rep1, class Period1, class Rep2, class Period2>
      constexpr common_type_t<Rep1, Rep2>
        operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
    

    Let CD be common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>.

    -10- Returns: CD(lhs).count() / CD(rhs).count().

Date: 2018-06-12.01:05:16

[ 2018-06 Rapperswil: Adopted ]

Date: 2018-04-24.00:00:00

[ 2018-04-24 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Date: 2018-04-17.00:00:00

[time.duration.nonmember]/1 states

In the function descriptions that follow, CD represents the return type of the function.

From what I could find, many definitions of CD in the paragraphs of [time.duration.nonmember] were lifted to [time.duration.nonmember]/1 as cited above. That works for all other paragraphs, but not for [time.duration.nonmember]/10, which the change rendered ill-formed:

template<class Rep1, class Period1, class Rep2, class Period2>
  constexpr common_type_t<Rep1, Rep2>
    operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
Returns: CD(lhs).count() / CD(rhs).count().

In this case, we want CD to mean common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>. That way, the division has the expected semantics of dividing two quantities of the same dimension.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-06-12 01:05:16adminsetmessages: + msg9893
2018-06-12 01:05:16adminsetstatus: voting -> wp
2018-05-06 19:23:13adminsetstatus: ready -> voting
2018-05-05 12:25:22adminsetmessages: + msg9833
2018-05-05 12:25:22adminsetstatus: new -> ready
2018-04-22 16:36:38adminsetmessages: + msg9828
2018-04-17 00:00:00admincreate